Untitled

 avatar
unknown
plain_text
2 years ago
15 kB
6
Indexable
page 60003 SalesOrderDetailStaging
{
    AutoSplitKey = true;
    Caption = 'Import Worksheet For SalesLine';
    DelayedInsert = true;
    InsertAllowed = false;
    ModifyAllowed = false;
    PageType = Worksheet;
    SaveValues = true;
    SourceTable = "Sales Order Detail Staging";
    // SourceTableView = sorting(Order_id, Order_detail_id, LineNo);
    UsageCategory = Tasks;
    ApplicationArea = All;


    layout
    {
        area(Content)
        {
            field(OrderID; OrderID)
            {
                ApplicationArea = All;

            }
            repeater(GroupName)
            {

                field(Order_detail_id; Rec.Order_detail_id)
                {
                    ApplicationArea = All;

                }


                field(Order_id; Rec.Order_id)
                {
                    ApplicationArea = All;

                }

                field(Product_id; Rec.Product_id)
                {
                    ApplicationArea = All;

                }

                field(Product_title; Rec.Product_title)
                {
                    ApplicationArea = All;

                }

                field(aza_online_code; Rec.aza_online_code)
                {
                    ApplicationArea = All;

                }

                field(Category_id; Rec.Category_id)
                {
                    ApplicationArea = All;

                }

                field(size_Name; Rec.size_Name)
                {
                    ApplicationArea = All;

                }

                field(designer_id; Rec.designer_id)
                {
                    ApplicationArea = All;

                }

                field(Colour_Name; Rec.Colour_Name)
                {
                    ApplicationArea = All;

                }

                field(quantity; Rec.quantity)
                {
                    ApplicationArea = All;

                }

                field(actual_quantity; Rec.actual_quantity)
                {
                    ApplicationArea = All;

                }

                field(Product_price; Rec.Product_price)
                {
                    ApplicationArea = All;

                }

                field(Product_cost; Rec.Product_cost)
                {
                    ApplicationArea = All;

                }

                field(Product_amount; Rec.Product_amount)
                {
                    ApplicationArea = All;

                }

                field(actual_Amount; Rec.actual_Amount)
                {
                    ApplicationArea = All;

                }

                field(discount_Precent; Rec.discount_Precent)
                {
                    ApplicationArea = All;

                }

                field(Discount_Precent_By_Desg; Rec.Discount_Precent_By_Desg)
                {
                    ApplicationArea = All;

                }

                field(Discount_Precent_By_Aza; Rec.Discount_Precent_By_Aza)
                {
                    ApplicationArea = All;

                }

                field(Promo_Discount; Rec.Promo_Discount)
                {
                    ApplicationArea = All;

                }

                field(Credit_by_Product; Rec.Credit_by_Product)
                {
                    ApplicationArea = All;

                }

                field(Loyalty_By_Product; Rec.Loyalty_By_Product)
                {
                    ApplicationArea = All;

                }

                field(tax_By_Product; Rec.tax_By_Product)
                {
                    ApplicationArea = All;

                }

                field(Shipping_Status; Rec.Shipping_Status)
                {
                    ApplicationArea = All;

                }

                field(is_return_And_Exchange; Rec.is_return_And_Exchange)
                {
                    ApplicationArea = All;

                }

                field(Shipping_Company_Name; Rec.Shipping_Company_Name)
                {
                    ApplicationArea = All;

                }

                field(Shipping_Company_NAme_rtv; Rec.Shipping_Company_NAme_rtv)
                {
                    ApplicationArea = All;

                }

                field(Tracking_id; Rec.Tracking_id)
                {
                    ApplicationArea = All;

                }

                field(tracking_id_rtv; Rec.tracking_id_rtv)
                {
                    ApplicationArea = All;

                }

                field(delivery_Date; Rec.delivery_Date)
                {
                    ApplicationArea = All;

                }

                field(delivery_date_rtv; Rec.delivery_date_rtv)
                {
                    ApplicationArea = All;

                }

                field(track_Date; Rec.track_Date)
                {
                    ApplicationArea = All;

                }

                field(track_Date_rtv; Rec.track_Date_rtv)
                {
                    ApplicationArea = All;

                }

                field(invoice_number; Rec.invoice_number)
                {
                    ApplicationArea = All;

                }

                field(invoice_number_rtv; Rec.invoice_number_rtv)
                {
                    ApplicationArea = All;

                }

                field(dispatch_date; Rec.dispatch_date)
                {
                    ApplicationArea = All;

                }
                field(in_Warehouse; Rec.in_Warehouse)
                {
                    ApplicationArea = All;

                }

                field(Ship_date; Rec.Ship_date)
                {
                    ApplicationArea = All;

                }

                field(Ship_Date_Rtv; Rec.Ship_Date_Rtv)
                {
                    ApplicationArea = All;

                }

                field(Weight; Rec.Weight)
                {
                    ApplicationArea = All;

                }

                field(Ship_Mode; Rec.Ship_Mode)
                {
                    ApplicationArea = All;

                }

                field(order_Confirm_Date; Rec.order_Confirm_Date)
                {
                    ApplicationArea = All;

                }

                field(Loyality_Points; Rec.Loyality_Points)
                {
                    ApplicationArea = All;

                }

                field(Loyalty_Flag; Rec.Loyalty_Flag)
                {
                    ApplicationArea = All;

                }

                field(estm_DElivery_Date; Rec.estm_DElivery_Date)
                {
                    ApplicationArea = All;

                }

                field(is_Customization_Received; Rec.is_Customization_Received)
                {
                    ApplicationArea = All;

                }

                field(Blouse_Customization_received; Rec.Blouse_Customization_received)
                {
                    ApplicationArea = All;

                }

                field(invoice_item_number; Rec.invoice_item_number)
                {
                    ApplicationArea = All;

                }

                field(alteration_charges; Rec.alteration_charges)
                {
                    ApplicationArea = All;

                }
                field(LineCreated; Rec.LineCreated)
                {
                    ApplicationArea = All;
                }
                field(Line_No; Rec.Line_No)
                {
                    ApplicationArea = All;
                }




            }
        }
        area(Factboxes)
        {

        }
    }

    actions
    {
        area(Processing)
        {
            action(Importdata)
            {
                ApplicationArea = All;
                Image = ImportExcel;
                PromotedCategory = Process;
                Promoted = true;
                ToolTip = 'ImportdataExcel';

                trigger OnAction();
                var
                begin
                    // if OrderID = '' then
                    //   Error('BatchISBlanckMsg');
                    ReadExelSheet();
                    ImportExelData();
                end;
            }
        }
    }
    var



        UploadExcelMsg: Label 'Please Choose the Excel file.';
        TempExcelBuffer: Record "Excel Buffer" temporary;
        NoFileFoundMsg: Label 'No Excel file found!';
        BatchISBlankMsg: Label 'Batch name is blank';
        ExcelImportSucess: Label 'Excel is successfully imported.';



        FileName: Text[50];
        Sheetname: Text[50];
        OrderID: Code[20];

    local procedure ReadExelSheet()
    var
        FileMang: Codeunit "File Management";
        Istream: InStream;
        FromFile: Text[100];
    begin
        UploadIntoStream(UploadExcelMsg, '', '', FromFile, Istream);
        if FromFile <> '' then begin
            FileName := FileMang.GetFileName(FromFile);
            Sheetname := TempExcelBuffer.SelectSheetsNameStream(Istream);
        end else
            Error('No File Found Msg');
        TempExcelBuffer.Reset();
        TempExcelBuffer.DeleteAll();
        TempExcelBuffer.OpenBookStream(Istream, Sheetname);
        TempExcelBuffer.ReadSheet();

    end;

    local procedure ImportExelData()
    var
        SalesOrderDetailStaging: Record "Sales Order Detail Staging";
        RowNo: Integer;
        ColomNo: Integer;
        LineNo: Integer;
        MAxRowNo: Integer;
    begin
        RowNo := 0;
        ColomNo := 0;
        LineNo := 0;
        MAxRowNo := 0;
        SalesOrderDetailStaging.Reset();
        if SalesOrderDetailStaging.FindLast() then
            LineNo := SalesOrderDetailStaging.Line_No;
        TempExcelBuffer.Reset();
        if TempExcelBuffer.FindLast() then begin
            MAxRowNo := TempExcelBuffer."Row No.";
        end;
        for RowNo := 2 to MAxRowNo do begin
            LineNo := LineNo + 10000;
            SalesOrderDetailStaging.Init();
            Evaluate(SalesOrderDetailStaging.Order_id, OrderID);
            SalesOrderDetailStaging.Line_No := LineNo;
            Evaluate(SalesOrderDetailStaging.Order_detail_id, GetvalueAtCell(RowNo, 2));
            Evaluate(SalesOrderDetailStaging.Order_id, GetvalueAtCell(RowNo, 3));
            Evaluate(SalesOrderDetailStaging.Product_id, GetvalueAtCell(RowNo, 4));
            Evaluate(SalesOrderDetailStaging.Product_title, GetvalueAtCell(RowNo, 5));
            Evaluate(SalesOrderDetailStaging.aza_online_code, GetvalueAtCell(RowNo, 6));
            Evaluate(SalesOrderDetailStaging.Category_id, GetvalueAtCell(RowNo, 7));
            Evaluate(SalesOrderDetailStaging.size_Name, GetvalueAtCell(RowNo, 8));
            Evaluate(SalesOrderDetailStaging.designer_id, GetvalueAtCell(RowNo, 9));
            Evaluate(SalesOrderDetailStaging.Colour_Name, GetvalueAtCell(RowNo, 10));

            Evaluate(SalesOrderDetailStaging.quantity, GetvalueAtCell(RowNo, 11));
            Evaluate(SalesOrderDetailStaging.actual_quantity, GetvalueAtCell(RowNo, 12));
            Evaluate(SalesOrderDetailStaging.Product_price, GetvalueAtCell(RowNo, 13));
            Evaluate(SalesOrderDetailStaging.Product_cost, GetvalueAtCell(RowNo, 14));
            Evaluate(SalesOrderDetailStaging.Product_amount, GetvalueAtCell(RowNo, 15));
            Evaluate(SalesOrderDetailStaging.actual_Amount, GetvalueAtCell(RowNo, 16));
            Evaluate(SalesOrderDetailStaging.discount_Precent, GetvalueAtCell(RowNo, 17));
            Evaluate(SalesOrderDetailStaging.Discount_Precent_By_Desg, GetvalueAtCell(RowNo, 18));
            Evaluate(SalesOrderDetailStaging.Discount_Precent_By_Aza, GetvalueAtCell(RowNo, 19));
            Evaluate(SalesOrderDetailStaging.Promo_Discount, GetvalueAtCell(RowNo, 20));
            Evaluate(SalesOrderDetailStaging.Credit_by_Product, GetvalueAtCell(RowNo, 21));
            Evaluate(SalesOrderDetailStaging.Loyalty_By_Product, GetvalueAtCell(RowNo, 22));
            Evaluate(SalesOrderDetailStaging.tax_By_Product, GetvalueAtCell(RowNo, 23));
            Evaluate(SalesOrderDetailStaging.Shipping_Status, GetvalueAtCell(RowNo, 24));
            Evaluate(SalesOrderDetailStaging.is_return_And_Exchange, GetvalueAtCell(RowNo, 25));
            Evaluate(SalesOrderDetailStaging.Shipping_Company_Name, GetvalueAtCell(RowNo, 26));
            Evaluate(SalesOrderDetailStaging.Shipping_Company_Name_rtv, GetvalueAtCell(RowNo, 27));
            Evaluate(SalesOrderDetailStaging.Tracking_id, GetvalueAtCell(RowNo, 28));
            Evaluate(SalesOrderDetailStaging.tracking_id_rtv, GetvalueAtCell(RowNo, 29));
            Evaluate(SalesOrderDetailStaging.delivery_Date, GetvalueAtCell(RowNo, 30));
            //          SalesOrderDetailStaging.Validate(delivery_Date);
            Evaluate(SalesOrderDetailStaging.delivery_date_rtv, GetvalueAtCell(RowNo, 31));

            Evaluate(SalesOrderDetailStaging.track_Date, GetvalueAtCell(RowNo, 32));
            //    SalesOrderDetailStaging.Validate(track_Date);
            Evaluate(SalesOrderDetailStaging.track_Date_rtv, GetvalueAtCell(RowNo, 33));
            //SalesOrderDetailStaging.Validate(track_Date_rtv);
            Evaluate(SalesOrderDetailStaging.invoice_number, GetvalueAtCell(RowNo, 34));
            Evaluate(SalesOrderDetailStaging.invoice_number_rtv, GetvalueAtCell(RowNo, 35));
            Evaluate(SalesOrderDetailStaging.dispatch_date, GetvalueAtCell(RowNo, 36));
            //SalesOrderDetailStaging.Validate(dispatch_date);
            Evaluate(SalesOrderDetailStaging.in_Warehouse, GetvalueAtCell(RowNo, 37));
            Evaluate(SalesOrderDetailStaging.Ship_date, GetvalueAtCell(RowNo, 38));
            //SalesOrderDetailStaging.Validate(Ship_date);
            Evaluate(SalesOrderDetailStaging.Ship_Date_Rtv, GetvalueAtCell(RowNo, 39));
            //SalesOrderDetailStaging.Validate(Ship_Date_Rtv);
            Evaluate(SalesOrderDetailStaging.Weight, GetvalueAtCell(RowNo, 40));
            Evaluate(SalesOrderDetailStaging.Ship_Mode, GetvalueAtCell(RowNo, 41));
            Evaluate(SalesOrderDetailStaging.order_Confirm_Date, GetvalueAtCell(RowNo, 42));
            Evaluate(SalesOrderDetailStaging.Loyality_Points, GetvalueAtCell(RowNo, 43));
            Evaluate(SalesOrderDetailStaging.Loyalty_Flag, GetvalueAtCell(RowNo, 44));
            Evaluate(SalesOrderDetailStaging.estm_DElivery_Date, GetvalueAtCell(RowNo, 45));
            Evaluate(SalesOrderDetailStaging.is_Customization_Received, GetvalueAtCell(RowNo, 46));
            Evaluate(SalesOrderDetailStaging.Blouse_Customization_received, GetvalueAtCell(RowNo, 47));
            Evaluate(SalesOrderDetailStaging.invoice_item_number, GetvalueAtCell(RowNo, 48));
            Evaluate(SalesOrderDetailStaging.alteration_charges, GetvalueAtCell(RowNo, 49));
            SalesOrderDetailStaging.Insert();
        end;
        Message('excelImportSuccess');
    end;

    local procedure GetvalueAtCell(RowNo: Integer; ColNo: Integer): Text
    begin
        TempExcelBuffer.Reset();
        if TempExcelBuffer.Get(RowNo, ColNo) then
            exit(TempExcelBuffer."Cell Value as Text")
        else
            exit('');
    end;

}
Editor is loading...