Пример #1
0
 protected void Page_PreRender(object sender, EventArgs e)
 {
     if (!X.IsAjaxRequest)
     {
         if (!IsPostBack)
         {
             ComboBoxBinding();
             DataBindList();
             LockControl();
             CmbReceipt.Focus();
         }
     }
 }
Пример #2
0
    protected void btnSave_Click(object sender, DirectEventArgs e)
    {
        if (string.IsNullOrEmpty(CmbReceipt.Value.Trim()))
        {
            div_bottom.Html = "<p class='error'> Save failed, From can't be empty!</p>";
            CmbReceipt.Focus();
            return;
        }
        if (string.IsNullOrEmpty(CmbFinalDest.Value.Trim()))
        {
            div_bottom.Html = "<p class='error'> Save failed, To can't be empty!</p>";
            CmbFinalDest.Focus();
            return;
        }
        if (string.IsNullOrEmpty(txtEst.RawText.Trim()))
        {
            div_bottom.Html = "<p class='error'> Save failed, Est Receipt can't be empty!</p>";
            txtEst.Focus(true);
            return;
        }
        if (string.IsNullOrEmpty(CmbShipperCode.Value.Trim()))
        {
            div_bottom.Html = "<p class='error'> Save failed, Shipper can't be empty!</p>";
            CmbShipperCode.Focus();
            return;
        }
        if (string.IsNullOrEmpty(CmbConsignee.Value.Trim()))
        {
            div_bottom.Html = "<p class='error'> Save failed, Consignee can't be empty!</p>";
            CmbConsignee.Focus();
            return;
        }
        if (string.IsNullOrEmpty(CmbSalesman.Value.Trim()))
        {
            div_bottom.Html = "<p class='error'> Save failed, Salesman can't be empty!</p>";
            CmbSalesman.Focus();
            return;
        }
        if (string.IsNullOrEmpty(txtPiece.Text.Trim()))
        {
            div_bottom.Html = "<p class='error'> Save failed, Piece(s) can't be empty!</p>";
            txtPiece.Focus(true);
            return;
        }

        List <IFields> UpdateHAWB = new List <IFields>();

        UpdateHAWB.Add(dal.CreateIFields().Append("Option", "Update")
                       .Append("air_Seed", hidSeed.Text == ""?null:hidSeed.Text)
                       .Append("air_ToMAWB", hidMAWB.Text == ""?null:hidMAWB.Text)

                       .Append("air_HAWB", txtHawb.Text.Trim().ToUpper())
                       .Append("air_CompanyReferance", txtReference.Text.Trim().ToUpper())
                       .Append("air_SpecicalDeal", chkSpecial.Checked ? "Y" : "N")
                       .Append("air_LocReceived", CmbReceipt.Value)
                       .Append("air_LocFinal", CmbFinalDest.Value)
                       .Append("air_EReceipt", ControlBinder.getDate(txtEst.RawText.Trim().ToUpper().StartsWith("0001") ? DBNull.Value : (object)txtEst.RawText.Trim()))
                       .Append("air_AReceipt", ControlBinder.getDate(txtAct.RawText.Trim().ToUpper().StartsWith("0001") ? DBNull.Value : (object)txtAct.RawText.Trim()))

                       .Append("air_Sales", CmbSalesman.Value)
                       //.Append("air_CSMode",txtCS.Text)
                       .Append("air_NP", CmbNP.SelectedItem.Value)

                       .Append("air_Shipper", CmbShipperCode.Value)
                       //.Append("air_Shipper", CmbShipperName.SelectedItem.Value)
                       .Append("air_Consignee", CmbConsignee.Value)
                       //.Append("air_Consignee", CmbConsigneeName.SelectedItem.Value)

                       .Append("air_PartyA", CmbNotify1.Value)
                       //.Append("air_PartyA", CmbNotify1Name.SelectedItem.Value)
                       .Append("air_PartyB", CmbNotify2.Value)
                       //.Append("air_PartyB", CmbNotify2Name.SelectedItem.Value)

                       .Append("air_GWT", string.IsNullOrEmpty(txtGWT.Text) ? DBNull.Value : (object)txtGWT.Text)
                       .Append("air_VWT", string.IsNullOrEmpty(txtVWT.Text) ? DBNull.Value : (object)txtVWT.Text)
                       .Append("air_CWT", string.IsNullOrEmpty(txtCWT.Text) ? DBNull.Value : (object)txtCWT.Text)
                       .Append("air_Piece", string.IsNullOrEmpty(txtPiece.Text) ? DBNull.Value : (object)txtPiece.Text)
                       .Append("air_Unit", CmbUnit.Value)
                       .Append("air_Pallet", string.IsNullOrEmpty(txtPallet.Text) ? DBNull.Value : (object)txtPallet.Text)
                       .Append("air_CBM", string.IsNullOrEmpty(txtCbf.Text) ? DBNull.Value : (object)txtCbf.Text)

                       .Append("code", FSecurityHelper.CurrentUserDataGET()[4].ToString() + sys)
                       .Append("code1", FSecurityHelper.CurrentUserDataGET()[4].ToString() + sys + "SN")
                       .Append("air_STAT", FSecurityHelper.CurrentUserDataGET()[12].ToString())
                       .Append("air_SYS", sys)
                       .Append("User", FSecurityHelper.CurrentUserDataGET()[0].ToString())
                       );
        try
        {
            DataSet ds = GetDs("FW_AirExport_SubShipment_SP", UpdateHAWB);
            hidSeed.Text = ds.Tables[0].Rows[0][0].ToString();
            string newFlag = ds.Tables[0].Rows[0][1].ToString();

            #region HAWBList
            var            HAWBList  = JSON.Deserialize <List <HAWBList> >(e.ExtraParams["p_safety_2"]);
            List <IFields> HAWBLists = new List <IFields>();
            string         RowID     = "";
            for (int i = 0; i < HAWBList.Count; ++i)
            {
                HAWBLists.Add(dal.CreateIFields().Append("Option", "UpdateEmptyHAWB").
                              Append("air_ROWID", HAWBList[i].RowID)
                              .Append("air_ToHAWB", hidSeed.Text));
                RowID += "," + HAWBList[i].RowID.ToString();
            }
            bool result = dal.FactoryDAL(PageHelper.ConnectionStrings, "FW_AirExport_SubShipment_SP", new List <IFields> {
                dal.CreateIFields().Append("Option", "AddSubShipmentByIDList")
                .Append("str", RowID).Append("User", FSecurityHelper.CurrentUserDataGET()[0].ToString()).Append("air_ToHAWB", hidSeed.Text)
            }).Update();
            dal.FactoryDAL(PageHelper.ConnectionStrings, "FW_AirExport_SubShipment_SP", HAWBLists).Update();
            #endregion

            #region Costing
            //X.AddScript("saveCost('" + hidSeed.Text + "');");

            ucCost.costseed = hidSeed.Text;
            ucCost.btnCostEvent(sender, e);
            #endregion

            #region LocalInvoice
            //var InvocieList = JSON.Deserialize<List<Invocie>>(e.ExtraParams["p_safety_invoice"]);
            //string InvoiceID = "";
            //for (int i = 0; i < InvocieList.Count; ++i)
            //{
            //    InvoiceID += "," + InvocieList[i].RowID;
            //}
            //if (InvoiceID.Length > 1)
            //{
            //    InvoiceID = InvoiceID.Substring(1, InvoiceID.Length - 1);
            //}
            //bool inv = dal.FactoryDAL(PageHelper.ConnectionStrings, "FW_AirExport_SubShipment_SP", new List<IFields>() { dal.CreateIFields().Append("Option", "DeleteInvoice")
            //.Append("air_ToHAWB",hidSeed.Text)
            //.Append("str",InvoiceID)}).Update();
            #endregion

            //update cost(Qty,unit,total)
            //ControlBinder.UpdateCostData(hidSeed.Text, "AE", "HAWB");
            if (newFlag == "N")
            {
                DataBindList();
                X.AddScript("if(window.opener!=null){if(typeof(window.opener.RefreshList)!='undefined'){window.opener.RefreshList();}}");
                ControlBinder.pageTitleMsg(false, "AE-H:" + hidLotNo.Text, "<p class=\"success\">Status : Save successfully ! </p>", div_bottom);
            }
            else
            {
                X.AddScript("if(window.opener!=null){if(typeof(window.opener.RefreshList)!='undefined'){window.opener.RefreshList();}}");
                ControlBinder.pageTitleMsg(false, "AE-H:" + hidLotNo.Text, "<p class=\"success\">Status : Save successfully ! </p>", div_bottom);
                X.Redirect("List.aspx?seed=" + ds.Tables[0].Rows[0][0] + "&MAWB=" + hidMAWB.Value);
            }
        }
        catch
        {
            ControlBinder.pageTitleMsg(false, "AE-H:" + hidLotNo.Text, "<p class=\"error\">Status : Save failed, please check the data !</p>", div_bottom);
        }
    }