コード例 #1
0
ファイル: pay_edit.aspx.cs プロジェクト: felix-wei/tsllog1806
    private void SaveBill()
    {
        #region save
        ASPxTextBox  oidCtr         = this.ASPxGridView1.FindEditFormTemplateControl("txt_Oid") as ASPxTextBox;
        ASPxComboBox partyTo        = this.ASPxGridView1.FindEditFormTemplateControl("cmb_PartyTo") as ASPxComboBox;
        ASPxTextBox  otherPartyName = this.ASPxGridView1.FindEditFormTemplateControl("txt_OtherPartyName") as ASPxTextBox;
        ASPxComboBox docType        = this.ASPxGridView1.FindEditFormTemplateControl("cbo_DocType") as ASPxComboBox;
        ASPxComboBox docType1       = this.ASPxGridView1.FindEditFormTemplateControl("cbo_DocType1") as ASPxComboBox;

        ASPxTextBox  docN    = this.ASPxGridView1.FindEditFormTemplateControl("txt_DocNo") as ASPxTextBox;
        ASPxDateEdit docDate = this.ASPxGridView1.FindEditFormTemplateControl("txt_DocDt") as ASPxDateEdit;
        ASPxMemo     remark  = this.ASPxGridView1.FindEditFormTemplateControl("txt_Remarks1") as ASPxMemo;

        ASPxButtonEdit docCurr = this.ASPxGridView1.FindEditFormTemplateControl("txt_Currency") as ASPxButtonEdit;
        ASPxSpinEdit   exRate  = this.ASPxGridView1.FindEditFormTemplateControl("txt_DocExRate") as ASPxSpinEdit;
        ASPxButtonEdit acCode  = this.ASPxGridView1.FindEditFormTemplateControl("txt_AcCode") as ASPxButtonEdit;

        ASPxTextBox  slipNo   = this.ASPxGridView1.FindEditFormTemplateControl("txt_SlipNo") as ASPxTextBox;
        ASPxTextBox  bankName = this.ASPxGridView1.FindEditFormTemplateControl("txt_BankName") as ASPxTextBox;
        ASPxTextBox  acDorc   = this.ASPxGridView1.FindEditFormTemplateControl("txt_AcDorc") as ASPxTextBox;
        ASPxTextBox  chqNo    = this.ASPxGridView1.FindEditFormTemplateControl("txt_ChequeNo") as ASPxTextBox;
        ASPxDateEdit chqDt    = this.ASPxGridView1.FindEditFormTemplateControl("txt_ChqDt") as ASPxDateEdit;
        ASPxTextBox  pic      = this.ASPxGridView1.FindEditFormTemplateControl("txt_Pic") as ASPxTextBox;

        ASPxSpinEdit docAmt   = this.ASPxGridView1.FindEditFormTemplateControl("spin_DocAmt") as ASPxSpinEdit;
        ASPxCheckBox isReturn = this.ASPxGridView1.FindEditFormTemplateControl("ck_IsReturn") as ASPxCheckBox;
        C2.pay_doc   inv      = Manager.ORManager.GetObject(typeof(pay_doc), SafeValue.SafeInt(oidCtr.Text, 0)) as pay_doc;
        if (null == inv)// first insert invoice
        {
            //string invN = C2Setup.GetNextNo("AR-RECEIPT");
            inv         = new C2.pay_doc();
            inv.PartyTo = SafeValue.SafeString(partyTo.Value, "");
            //inv.DocNo = invN;
            inv.DocType     = docType.Value.ToString();
            inv.DocType1    = docType1.Value.ToString();
            inv.DocDate     = docDate.Date;
            inv.ChqDate     = chqDt.Date;
            inv.Remark      = remark.Text;
            inv.DocCurrency = docCurr.Text.ToString();
            inv.DocExRate   = SafeValue.SafeDecimal(exRate.Value, 1);
            if (inv.DocExRate <= 0)
            {
                inv.DocExRate = 1;
            }
            inv.AcCode    = acCode.Text;
            inv.BankName  = bankName.Text;
            inv.SlipNo    = slipNo.Text;
            inv.ChqNo     = chqNo.Text;
            inv.ExportInd = "N";

            if (inv.DocType1.ToLower() == "refund")
            {
                inv.AcSource = "CR";
            }
            else
            {
                inv.AcSource = "DB";
            }

            inv.DocAmt         = SafeValue.SafeDecimal(docAmt.Value, 0);
            inv.LocAmt         = inv.DocAmt * inv.DocExRate;
            inv.CancelDate     = new DateTime(1900, 1, 1);
            inv.CancelInd      = "N";
            inv.BankRec        = "N";
            inv.BankDate       = new DateTime(1900, 1, 1);
            inv.OtherPartyName = otherPartyName.Text;
            string[] currentPeriod = EzshipHelper.GetAccPeriod(docDate.Date);
            inv.AcYear   = SafeValue.SafeInt(currentPeriod[1], docDate.Date.Year);
            inv.AcPeriod = SafeValue.SafeInt(currentPeriod[0], docDate.Date.Month);
            inv.Pic      = pic.Text;
            inv.IsReturn = isReturn.Checked;
            try
            {
                inv.GenerateInd    = "N";
                inv.CreateBy       = HttpContext.Current.User.Identity.Name;
                inv.CreateDateTime = DateTime.Now;
                inv.UpdateBy       = HttpContext.Current.User.Identity.Name;
                inv.UpdateDateTime = DateTime.Now;
                inv.PostBy         = "";
                inv.PostDateTime   = new DateTime(1900, 1, 1);
                C2.Manager.ORManager.StartTracking(inv, Wilson.ORMapper.InitialState.Inserted);
                C2.Manager.ORManager.PersistChanges(inv);
                inv.DocNo = inv.Id.ToString();
                C2.Manager.ORManager.StartTracking(inv, Wilson.ORMapper.InitialState.Updated);
                C2.Manager.ORManager.PersistChanges(inv);
                //C2Setup.SetNextNo("AR-RECEIPT", invN);
            }
            catch
            {
            }
        }
        else
        {
            inv.PartyTo     = SafeValue.SafeString(partyTo.Value, "");
            inv.DocDate     = docDate.Date;
            inv.ChqDate     = chqDt.Date;
            inv.Remark      = remark.Text;
            inv.DocCurrency = docCurr.Text.ToString();
            inv.DocExRate   = SafeValue.SafeDecimal(exRate.Value, 1);
            if (inv.DocExRate <= 0)
            {
                inv.DocExRate = 1;
            }
            inv.AcCode   = acCode.Text;
            inv.BankName = bankName.Text;
            inv.SlipNo   = slipNo.Text;
            inv.ChqNo    = chqNo.Text;
            inv.DocAmt   = SafeValue.SafeDecimal(docAmt.Value, 0);
            inv.LocAmt   = inv.DocAmt * inv.DocExRate;
            string[] currentPeriod = EzshipHelper.GetAccPeriod(docDate.Date);
            inv.AcYear   = SafeValue.SafeInt(currentPeriod[1], docDate.Date.Year);
            inv.AcPeriod = SafeValue.SafeInt(currentPeriod[0], docDate.Date.Month);

            inv.OtherPartyName = otherPartyName.Text;
            inv.Pic            = pic.Text;
            inv.IsReturn       = isReturn.Checked;
            try
            {
                inv.UpdateBy       = HttpContext.Current.User.Identity.Name;
                inv.UpdateDateTime = DateTime.Now;
                Manager.ORManager.StartTracking(inv, InitialState.Updated);
                Manager.ORManager.PersistChanges(inv);
            }
            catch
            { }
        }

        ASPxWebControl.RedirectOnCallback("pay_edit.aspx?no=" + inv.DocNo);
        //Session["ArRecWhere"] = "Id=" + inv.Id;
        //this.dsArReceipt.FilterExpression = Session["ArRecWhere"].ToString();
        //if (this.ASPxGridView1.GetRow(0) != null)
        //    this.ASPxGridView1.StartEdit(0);
        #endregion
    }
コード例 #2
0
    protected void ASPxGridView1_CustomDataCallback(object sender, ASPxGridViewCustomDataCallbackEventArgs e)
    {
        string s = e.Parameters;

        if (s == "Save")
        {
            C2.pay_doc   inv               = new C2.pay_doc();
            ASPxComboBox txtCustomerId     = ASPxPopupControl1.FindControl("cmb_Customer") as ASPxComboBox;
            ASPxDateEdit txtDocDt          = ASPxPopupControl1.FindControl("txt_DocDt") as ASPxDateEdit;
            ASPxTextBox  txtAcDorc         = ASPxPopupControl1.FindControl("txt_AcDorc") as ASPxTextBox;
            ASPxComboBox cboDocType        = ASPxPopupControl1.FindControl("cbo_DocType") as ASPxComboBox;
            ASPxComboBox cboDocType1       = ASPxPopupControl1.FindControl("cbo_DocType1") as ASPxComboBox;
            ASPxTextBox  txtOtherPartyName = ASPxPopupControl1.FindControl("txt_OtherPartyName") as ASPxTextBox;

            inv.PartyTo = SafeValue.SafeString(txtCustomerId.Value, "");
            //inv.DocNo = invN;
            inv.DocType     = cboDocType.Text;
            inv.DocType1    = cboDocType1.Text;
            inv.DocDate     = txtDocDt.Date;
            inv.ChqDate     = txtDocDt.Date;
            inv.AcCode      = System.Configuration.ConfigurationManager.AppSettings["DefaultBankCode"];
            inv.DocCurrency = System.Configuration.ConfigurationManager.AppSettings["Currency"];
            inv.DocExRate   = new decimal(1.0);
            inv.ExportInd   = "N";

            if (inv.DocType1.ToLower() == "refund")
            {
                inv.AcSource = "CR";
            }
            else
            {
                inv.AcSource = "DB";
            }

            inv.DocAmt         = 0;
            inv.LocAmt         = 0;
            inv.CancelDate     = new DateTime(1900, 1, 1);
            inv.CancelInd      = "N";
            inv.BankRec        = "N";
            inv.BankDate       = new DateTime(1900, 1, 1);
            inv.OtherPartyName = txtOtherPartyName.Text;
            string[] currentPeriod = EzshipHelper.GetAccPeriod(txtDocDt.Date);
            inv.AcYear   = SafeValue.SafeInt(currentPeriod[1], txtDocDt.Date.Year);
            inv.AcPeriod = SafeValue.SafeInt(currentPeriod[0], txtDocDt.Date.Month);
            try
            {
                inv.GenerateInd    = "N";
                inv.CreateBy       = HttpContext.Current.User.Identity.Name;
                inv.CreateDateTime = DateTime.Now;
                inv.UpdateBy       = HttpContext.Current.User.Identity.Name;
                inv.UpdateDateTime = DateTime.Now;
                inv.PostBy         = "";
                inv.PostDateTime   = new DateTime(1900, 1, 1);
                C2.Manager.ORManager.StartTracking(inv, Wilson.ORMapper.InitialState.Inserted);
                C2.Manager.ORManager.PersistChanges(inv);
                inv.DocNo = inv.Id.ToString();
                C2.Manager.ORManager.StartTracking(inv, Wilson.ORMapper.InitialState.Updated);
                C2.Manager.ORManager.PersistChanges(inv);
                //C2Setup.SetNextNo("AR-RECEIPT", invN);
            }
            catch
            {
            }
            e.Result = inv.DocNo;
        }
    }