コード例 #1
0
ファイル: ArCnEdit.aspx.cs プロジェクト: felix-wei/tsllog1806
    protected void grid_InvDet_RowInserting(object sender, DevExpress.Web.Data.ASPxDataInsertingEventArgs e)
    {
        if (SafeValue.SafeString(e.NewValues["AcCode"], "").Length < 1)
        {
            e.Cancel = true;
            throw new Exception("Pls select the charge code");
        }
        ASPxGridView grd        = sender as ASPxGridView;
        string       sql_detCnt = "select count(DocId) from XAArInvoiceDet where DocId='" + SafeValue.SafeInt(grd.GetMasterRowKeyValue(), 0) + "'";
        int          lineNo     = SafeValue.SafeInt(Manager.ORManager.ExecuteScalar(sql_detCnt), 0) + 1;

        e.NewValues["CostingId"] = "";
        e.NewValues["DocId"]     = SafeValue.SafeInt(grd.GetMasterRowKeyValue(), 0);
        e.NewValues["DocLineNo"] = lineNo;
        ASPxTextBox  docN    = this.ASPxGridView1.FindEditFormTemplateControl("txt_DocNo") as ASPxTextBox;
        ASPxComboBox docType = this.ASPxGridView1.FindEditFormTemplateControl("cbo_DocType") as ASPxComboBox;

        e.NewValues["DocNo"]   = docN.Text;
        e.NewValues["DocType"] = docType.Text;
        if (!e.NewValues["Currency"].Equals("SGD"))
        {
            e.NewValues["GstType"] = "Z";
            e.NewValues["Gst"]     = new decimal(0);
        }
        if (SafeValue.SafeDecimal(e.NewValues["ExRate"], 1) == 0)
        {
            e.NewValues["ExRate"] = 1;
        }
        decimal amt    = SafeValue.ChinaRound(SafeValue.SafeDecimal(e.NewValues["Qty"], 0) * SafeValue.SafeDecimal(e.NewValues["Price"], 0), 2);
        decimal gstAmt = SafeValue.ChinaRound((amt * SafeValue.SafeDecimal(e.NewValues["Gst"], 0)), 2);
        decimal docAmt = amt + gstAmt;
        decimal locAmt = SafeValue.ChinaRound(docAmt * SafeValue.SafeDecimal(e.NewValues["ExRate"], 1), 2);

        e.NewValues["GstAmt"] = gstAmt;
        e.NewValues["DocAmt"] = docAmt;
        e.NewValues["LocAmt"] = locAmt;
        if (SafeValue.SafeString(e.NewValues["JobRefNo"]).Length > 1)
        {
            e.NewValues["SplitType"] = "SET";
        }
    }
コード例 #2
0
    protected void ASPxGridView1_CustomDataCallback(object sender, DevExpress.Web.ASPxGridView.ASPxGridViewCustomDataCallbackEventArgs e)
    {
        if (Request.QueryString["partyTo"] != null && Request.QueryString["no"] != null)
        {
            int repId = SafeValue.SafeInt(Request.QueryString["no"], 0);
            if (true)//locAmt == totPayAmt)
            {
                try
                {
                    for (int i = 0; i < list.Count; i++)
                    {
                        string  docId  = list[i].docId;
                        decimal payAmt = list[i].payAmt;

                        string    sql = string.Format("SELECT SequenceId,DocAmt,LocAmt,BalanceAmt,AcCode, AcSource, DocType,DocNo,DocDate,PartyTo,CurrencyId, ExRate FROM XAArInvoice where SequenceId='{0}'", docId);
                        DataTable tab = C2.Manager.ORManager.GetDataSet(sql).Tables[0];
                        if (tab.Rows.Count == 1)
                        {
                            string  docNo    = tab.Rows[0]["DocNo"].ToString();
                            string  docType  = tab.Rows[0]["DocType"].ToString();
                            string  acCode   = tab.Rows[0]["AcCode"].ToString();
                            string  acSource = tab.Rows[0]["AcSource"].ToString();
                            string  currency = tab.Rows[0]["CurrencyId"].ToString();
                            decimal exRate   = SafeValue.SafeDecimal(tab.Rows[0]["ExRate"], 1);
                            if (exRate == 0)
                            {
                                exRate = 1;
                            }
                            DateTime docDate       = SafeValue.SafeDate(tab.Rows[0]["DocDate"], DateTime.Now);
                            string   oid           = tab.Rows[0]["SequenceId"].ToString();
                            decimal  billDocAmt    = SafeValue.SafeDecimal(tab.Rows[0]["DocAmt"], 0);
                            decimal  billBalaceAmt = SafeValue.SafeDecimal(tab.Rows[0]["BalanceAmt"], 0);
                            decimal  billLocAmt    = SafeValue.SafeDecimal(tab.Rows[0]["LocAmt"], 0);

                            C2.XAArReceiptDet repDet = new XAArReceiptDet();
                            repDet.AcCode   = acCode;
                            repDet.AcSource = "DB";
                            repDet.Currency = currency;
                            repDet.DocAmt   = payAmt;// payAmt;
                            repDet.DocDate  = docDate;
                            repDet.DocId    = SafeValue.SafeInt(docId, 0);
                            repDet.DocNo    = docNo;
                            repDet.DocType  = docType;
                            repDet.ExRate   = exRate;
                            if (exRate == 1)
                            {
                                repDet.LocAmt = SafeValue.ChinaRound(payAmt * exRate, 2);
                            }
                            else
                            {
                                if (payAmt == billDocAmt)// full payment
                                {
                                    repDet.LocAmt = billLocAmt;
                                }
                                else if (payAmt == billBalaceAmt)//pay all outstanding amt
                                {
                                    repDet.LocAmt = billLocAmt - PayLocAmt_cn(oid);
                                }
                                else
                                {
                                    repDet.LocAmt = SafeValue.ChinaRound(payAmt * exRate, 2);//partal payment
                                }
                            }

                            repDet.RepLineNo = SafeValue.SafeInt(C2.Manager.ORManager.ExecuteScalar("select count(*) from XAArReceiptDet where RepId='" + repId + "'"), 0) + 1;
                            repDet.RepId     = repId;
                            repDet.RepNo     = SafeValue.SafeString(Manager.ORManager.ExecuteScalar("select DocNo from xaarreceipt where sequenceid=" + repId), "");
                            repDet.RepType   = "PC";
                            repDet.Remark1   = "Pay for " + docType + "-" + docNo;
                            repDet.Remark2   = "Pay made for party -" + acCode;
                            repDet.Remark3   = " ";
                            C2.Manager.ORManager.StartTracking(repDet, Wilson.ORMapper.InitialState.Inserted);
                            C2.Manager.ORManager.PersistChanges(repDet);

                            //update to doc

                            int res = UpdateBalance(docId, docType);
                        }
                    }
                    e.Result = "";
                }
                catch { }
            }
            else
            {
                e.Result = "The total amount must be match with the Cheque amount!";
            }
        }
        else
        {
            e.Result = "Please keyin select party ";
        }
    }
コード例 #3
0
 protected void grid_InvDet_RowUpdating(object sender, DevExpress.Web.Data.ASPxDataUpdatingEventArgs e)
 {
     if (SafeValue.SafeString(e.NewValues["GstType"], "") == "S")
     {
         e.NewValues["Gst"] = (decimal)0.07;
     }
     else
     {
         e.NewValues["Gst"] = (decimal)0;
     }
     e.NewValues["Amt"] = SafeValue.SafeDecimal(e.NewValues["Price"], 0) * SafeValue.SafeDecimal(e.NewValues["Qty"], 1) * (1 + SafeValue.SafeDecimal(e.NewValues["Gst"], 0));
 }
コード例 #4
0
    protected void grid_CustomDataCallback(object sender, ASPxGridViewCustomDataCallbackEventArgs e)
    {
        string par = e.Parameters;

        string[] ar = par.Split('_');
        if (par == "OK")
        {
            #region Create Inv
            if (Request.QueryString["no"] != null)
            {
                try
                {
                    bool   action = false;
                    string res    = "";
                    string no     = SafeValue.SafeString(Request.QueryString["no"]);
                    string type   = SafeValue.SafeString(Request.QueryString["type"]);
                    if (type == "IMP" || type == "EXP")
                    {
                        string sql_c = string.Format(@"select count(*) from ctm_jobdet1 where JobNo='{0}' and StatusCode!='Completed'", no);
                        int    n     = SafeValue.SafeInt(ConnectSql.ExecuteScalar(sql_c), 0);
                        n = 0;
                        if (n == 0)
                        {
                            action = true;
                        }
                        else
                        {
                            res = "Action Error!Not Completed Container,Can not Create Invoice";
                        }
                    }
                    else
                    {
                        action = true;
                    }
                    if (action)
                    {
                        #region Create Inv
                        string docId = "";
                        if (list.Count > 0)
                        {
                            string   billType = SafeValue.SafeString(cbb_BillType.Value);
                            string   jobNo    = SafeValue.SafeString(Request.QueryString["no"]);
                            string   client   = SafeValue.SafeString(Request.QueryString["client"]);
                            string   contType = SafeValue.SafeString(Request.QueryString["contType"]);
                            string   user     = HttpContext.Current.User.Identity.Name;
                            string   acCode   = EzshipHelper.GetAccArCode("", "SGD");
                            DateTime dtime    = txt_DocDt.Date;
                            string   invN     = C2Setup.GetNextNo("", "AR-IV", dtime);
                            string   termId   = EzshipHelper.GetTerm(client);
                            string   term     = EzshipHelper.GetTermCode(termId);
                            string   currency = cmb_CurrencyId.Text;
                            decimal  exrate   = SafeValue.SafeDecimal(spin_ExRate.Value);
                            string   sql_att  = string.Format(@"select ClientContact from ctm_job where JobNo='{0}'", jobNo);
                            string   contact  = SafeValue.SafeString(ConnectSql.ExecuteScalar(sql_att));

                            string[] currentPeriod = EzshipHelper.GetAccPeriod(dtime);
                            string   acYear        = currentPeriod[1];
                            string   acPeriod      = currentPeriod[0];

                            string sql = string.Format(@"insert into XAArInvoice (DocType,DocDate,PartyTo,DocNo,AcYear,AcPeriod,Term,DocDueDate,Description,
CurrencyId,MastType,ExRate,ExportInd,CancelDate,CancelInd,UserId,EntryDate,Eta,AcCode,AcSource,MastRefNo,Contact)
values('IV','{5:yyyy-MM-dd}','{4}','{0}','{6}','{7}','{8}','{5:yyyy-MM-dd}','',
'{9}','CTM',{10},'N','19000101','N','{1}',getdate(),'17530101','{2}','DB','{3}','{11}')
select @@IDENTITY", invN, user, acCode, jobNo, client, dtime, acYear, acPeriod, term, currency, exrate, contact);
                            docId = ConnectSql_mb.ExecuteScalar(sql);
                            C2Setup.SetNextNo("", "AR-IV", invN, dtime);
                            string code = "";
                            for (int i = 0; i < list.Count; i++)
                            {
                                int    id         = list[i].id;
                                string chgCode    = list[i].chgCode;
                                string chgcodeDes = list[i].chgCodedes;
                                if (IsCostCreated(id))
                                {
                                    C2.ComMethod.CreateInv(invN, id, docId, i, billType, currency, exrate);
                                }
                                else
                                {
                                    if (list.Count - i > 1)
                                    {
                                        code += chgcodeDes + " / ";
                                    }
                                    else
                                    {
                                        code += chgcodeDes;
                                    }
                                }
                            }
                            for (int i = 0; i < list1.Count; i++)
                            {
                                int    id      = list1[i].id;
                                string chgCode = list[i].chgCode;
                                if (IsCostCreated(id))
                                {
                                    C2.ComMethod.CreateWhInv(invN, id, docId);
                                }
                                else
                                {
                                    if (list.Count - i > 1)
                                    {
                                        code += chgCode + " / ";
                                    }
                                    else
                                    {
                                        code += chgCode;
                                    }
                                }
                            }
                            C2.XAArInvoice.update_invoice_mast(SafeValue.SafeInt(docId, 0));
                            if (code.Length == 0)
                            {
                                e.Result = invN;
                            }
                            else
                            {
                                e.Result = "Action Error!" + code + " already exist !";
                            }
                        }
                        else
                        {
                            e.Result = "Action Error!Please keyin select cost ";
                        }
                        #endregion

                        string            userId = HttpContext.Current.User.Identity.Name;
                        C2.CtmJobEventLog elog   = new C2.CtmJobEventLog();
                        elog.Platform_isWeb();
                        elog.Controller = userId;
                        elog.ActionLevel_isINVOICE(SafeValue.SafeInt(docId, 0));
                        elog.setActionLevel(SafeValue.SafeInt(docId, 0), CtmJobEventLogRemark.Level.Invoice, 3);
                        elog.log();
                    }
                    else
                    {
                        e.Result = res;
                    }
                }
                catch { }
            }
            #endregion
        }
        if (par == "Update")
        {
            #region Update Inv
            if (Request.QueryString["no"] != null)
            {
                try
                {
                    string no = SafeValue.SafeString(Request.QueryString["no"]);
                    if (list.Count > 0)
                    {
                        string  invN     = lbl_DocNo.Text;
                        string  sql      = string.Format(@"select SequenceId from  XAArInvoice where DocNo='{0}'", invN);
                        string  docId    = ConnectSql_mb.ExecuteScalar(sql);
                        string  currency = cmb_CurrencyId.Text;
                        decimal exrate   = SafeValue.SafeDecimal(spin_ExRate.Value);
                        string  code     = "";
                        for (int i = 0; i < list.Count; i++)
                        {
                            int    id         = list[i].id;
                            string chgCode    = list[i].chgCode;
                            string chgcodeDes = list[i].chgCodedes;
                            if (IsCostCreated(id))
                            {
                                C2.ComMethod.CreateInv(invN, id, docId, i, "", currency, exrate);
                            }
                            else
                            {
                                if (list.Count - i > 1)
                                {
                                    code += chgcodeDes + " / ";
                                }
                                else
                                {
                                    code += chgcodeDes;
                                }
                            }
                        }
                        if (code.Length == 0)
                        {
                            e.Result = invN;
                        }
                        else
                        {
                            e.Result = "Action Error!" + code + " already exist !";
                        }
                    }
                    else
                    {
                        e.Result = "Action Error!Please keyin select cost ";
                    }
                }
                catch (Exception ex) { throw new Exception(ex.Message + ex.StackTrace); }
            }
            #endregion
        }
        if (par == "Save")
        {
            #region Save All
            if (list.Count > 0)
            {
                for (int i = 0; i < list.Count; i++)
                {
                    int     id        = list[i].id;
                    string  contNo    = list[i].contNo;
                    string  contType  = list[i].contType;
                    decimal price     = list[i].price;
                    decimal qty       = list[i].qty;
                    string  unit      = list[i].unit;
                    string  code      = list[i].chgCode;
                    string  des       = list[i].chgCodedes;
                    int     lineIndex = list[i].lineIndex;
                    string  remark    = list[i].remark;
                    string  groupBy   = list[i].groupBy;
                    decimal locAmt    = SafeValue.ChinaRound(qty * SafeValue.SafeDecimal(price, 0), 2);
                    string  sql       = string.Format(@"update job_cost set ContNo='{0}',ContType='{1}',Price={2},Qty={3},LocAmt={4},Unit='{6}',ChgCode='{7}',ChgCodeDes='{8}',LineIndex={9},Remark='{10}',GroupBy='{11}' where Id={5}",
                                                      contNo, contType, price, qty, locAmt, id, unit, code, des, lineIndex, remark, groupBy);
                    ConnectSql.ExecuteSql(sql);
                }
                e.Result = "Save Success";
            }
            else
            {
                e.Result = "Action Error!Please keyin select cost ";
            }
            #endregion
        }
        if (par == "Delete")
        {
            #region
            if (list.Count > 0)
            {
                bool   action = false;
                string no     = SafeValue.SafeString(Request.QueryString["no"]);
                for (int i = 0; i < list.Count; i++)
                {
                    int    id     = list[i].id;
                    string sql    = string.Format(@"select LineSource from job_cost where Id={0}", id);
                    string status = SafeValue.SafeString(ConnectSql_mb.ExecuteScalar(sql));
                    if (status != "S")
                    {
                        action = true;
                        sql    = string.Format(@"delete from job_cost where Id={0}", id);
                        ConnectSql.ExecuteSql(sql);
                    }
                    else
                    {
                        e.Result = "this can not delete ";
                    }
                }
                if (action)
                {
                    e.Result = "Action Success";
                }
            }
            else
            {
                e.Result = "Please keyin select cost ";
            }
            #endregion
        }
        if (ar.Length >= 2)
        {
            if (ar[0].Equals("ChargeUpdateline"))
            {
                Update_Inline(e);
            }
        }
    }
コード例 #5
0
    protected void grid1_CustomDataCallback(object sender, ASPxGridViewCustomDataCallbackEventArgs e)
    {
        if (Request.QueryString["no"] != null)
        {
            try
            {
                if (list.Count > 0)
                {
                    string jobNo   = SafeValue.SafeString(Request.QueryString["no"]);
                    string jobType = SafeValue.SafeString(Request.QueryString["type"]);
                    string result  = "";
                    string code    = "";
                    for (int i = 0; i < list.Count; i++)
                    {
                        int id = list[i].id;
                        Wilson.ORMapper.OPathQuery query = new Wilson.ORMapper.OPathQuery(typeof(C2.JobRate), "Id=" + id + "");
                        C2.JobRate rate = C2.Manager.ORManager.GetObject(query) as C2.JobRate;

                        if (rate != null)
                        {
                            #region Container
                            if (rate.BillScope.ToUpper() == "CONT")
                            {
                                string    sql_cont = string.Format(@"select ContainerNo,ContainerType from CTM_JobDet1 where JobNo='{0}'", jobNo);
                                DataTable dt       = ConnectSql.GetTab(sql_cont);
                                for (int a = 0; a < dt.Rows.Count; a++)
                                {
                                    string  contNo   = SafeValue.SafeString(dt.Rows[a]["ContainerNo"]);
                                    string  contType = SafeValue.SafeString(dt.Rows[a]["ContainerType"]);
                                    string  str      = contType.Substring(0, 2);
                                    decimal price    = 0;
                                    string  sql      = string.Format(@"select count(*) from job_cost where ContNo='{0}' and ChgCode='{1}'", contNo, rate.ChgCode);
                                    int     n        = SafeValue.SafeInt(ConnectSql_mb.ExecuteScalar(sql), 0);
                                    if (n == 0)
                                    {
                                        C2.Job_Cost cost = new Job_Cost();
                                        cost.JobNo      = jobNo;
                                        cost.CurrencyId = System.Configuration.ConfigurationManager.AppSettings["Currency"];
                                        cost.ExRate     = new decimal(1.0);
                                        cost.ContNo     = contNo;
                                        cost.ContType   = contType;
                                        cost.ChgCode    = rate.ChgCode;
                                        if (rate.ChgCode.ToUpper().Equals("TRUCKING"))
                                        {
                                            cost.ChgCodeDe = rate.ChgCode;
                                        }
                                        else
                                        {
                                            cost.ChgCodeDe = rate.ChgCodeDe;
                                        }
                                        cost.BillClass  = "TRUCKING";
                                        cost.BillScope  = "CONT";
                                        cost.LineSource = "M";
                                        cost.JobType    = jobType;
                                        cost.Qty        = 1;
                                        cost.Unit       = "";
                                        cost.LineType   = "CONT";
                                        cost.LocAmt     = SafeValue.ChinaRound(1 * SafeValue.SafeDecimal(rate.Price, 0), 2);
                                        if (rate.ContSize == str)
                                        {
                                            cost.Price = rate.Price;
                                            Manager.ORManager.StartTracking(cost, Wilson.ORMapper.InitialState.Inserted);
                                            Manager.ORManager.PersistChanges(cost);
                                        }
                                        else if (rate.ContSize.Length == 0)
                                        {
                                            cost.Price = rate.Price;
                                            Manager.ORManager.StartTracking(cost, Wilson.ORMapper.InitialState.Inserted);
                                            Manager.ORManager.PersistChanges(cost);
                                        }
                                        result = "Success";
                                    }
                                    else
                                    {
                                        code += contNo + " Had " + rate.ChgCodeDe + " / ";
                                    }
                                }
                            }
                            #endregion
                            #region Other
                            else
                            {
                                string sql = string.Format(@"select count(*) from job_cost where JobNo='{0}' and ChgCode='{1}'", jobNo, rate.ChgCode);
                                int    n   = SafeValue.SafeInt(ConnectSql_mb.ExecuteScalar(sql), 0);
                                if (n == 0)
                                {
                                    C2.Job_Cost cost = new Job_Cost();
                                    cost.JobNo      = jobNo;
                                    cost.JobType    = jobType;
                                    cost.CurrencyId = System.Configuration.ConfigurationManager.AppSettings["Currency"];
                                    cost.ExRate     = new decimal(1.0);
                                    cost.ContNo     = "";
                                    cost.ContType   = "";
                                    cost.ChgCode    = rate.ChgCode;
                                    cost.ChgCodeDe  = rate.ChgCodeDe;
                                    cost.Qty        = 1;
                                    cost.Unit       = "";
                                    cost.Price      = rate.Price;
                                    cost.LineType   = "JOB";
                                    cost.BillClass  = rate.BillClass;
                                    cost.BillScope  = rate.BillScope;
                                    cost.LineSource = "M";
                                    cost.LocAmt     = SafeValue.ChinaRound(1 * SafeValue.SafeDecimal(rate.Price, 0), 2);
                                    Manager.ORManager.StartTracking(cost, Wilson.ORMapper.InitialState.Inserted);
                                    Manager.ORManager.PersistChanges(cost);
                                }
                                else
                                {
                                    code += rate.ChgCodeDe + " ";
                                }
                                result = "Success";
                            }
                            #endregion
                        }
                    }
                    if (code.Length > 0)
                    {
                        e.Result = code;
                    }
                    else
                    {
                        e.Result = result;
                    }
                }
                else
                {
                    e.Result = "Pls Select at least one Rate";
                }
            }
            catch { }
        }
    }
コード例 #6
0
    protected void grid_CustomDataCallback(object sender, DevExpress.Web.ASPxGridView.ASPxGridViewCustomDataCallbackEventArgs e)
    {
        if (Request.QueryString["id"] != null && Request.QueryString["no"] != null)
        {
            string    invNo    = Request.QueryString["no"].ToString();
            int       invId    = SafeValue.SafeInt(Request.QueryString["id"], 0);
            string    refNo    = "";
            string    jobNo    = "";
            string    mastType = "";
            string    docType  = "";
            string    sql_mast = string.Format("select DocType,MastRefNo,JobRefNo,MastType from XAApPayable where SequenceId='{0}'", invId);
            DataTable tab_mast = C2.Manager.ORManager.GetDataSet(sql_mast).Tables[0];
            if (tab_mast.Rows.Count == 1)
            {
                docType  = SafeValue.SafeString(tab_mast.Rows[0]["DocType"]);
                refNo    = SafeValue.SafeString(tab_mast.Rows[0]["MastRefNo"]);
                jobNo    = SafeValue.SafeString(tab_mast.Rows[0]["JobRefNo"]);
                mastType = SafeValue.SafeString(tab_mast.Rows[0]["MastType"]);
            }

            if (mastType == "SI")
            {
                sql_mast = string.Format("Select round(case when Weight/1000>volume then Weight/1000 else Volume end,3) FROM SeaImport where RefNo='{0}' and JobNo='{1}'", refNo, jobNo);
            }
            else if (mastType == "SE")
            {
                sql_mast = string.Format("Select round(case when Weight/1000>volume then Weight/1000 else Volume end,3) FROM SeaExport where RefNo='{0}' and JobNo='{1}'", refNo, jobNo);
            }
            decimal qty = SafeValue.SafeDecimal(C2.Manager.ORManager.ExecuteScalar(sql_mast), 0);

            int index = SafeValue.SafeInt(C2.Manager.ORManager.ExecuteScalar(string.Format("Select max(DocLineNo) FROM XAApPayableDet where DocId='{0}'", invId)), 0);
            for (int i = 0; i < list.Count; i++)
            {
                try
                {
                    index++;
                    int sequenceId = list[i].docId;

                    string    sql = string.Format(@"SELECT  ChgCode, ChgDes, Currency, ExRate,Price, Unit, MinAmt, Rmk, Qty, Amt, GstType, Gst
 FROM SeaApQuoteDet1 where SequenceId='{0}' order by QuoteLineNo", sequenceId);
                    DataTable tab = C2.Manager.ORManager.GetDataSet(sql).Tables[0];
                    if (tab.Rows.Count == 1)
                    {
                        string chgCode  = tab.Rows[0]["ChgCode"].ToString();
                        string acCode   = SafeValue.SafeString(C2.Manager.ORManager.ExecuteScalar(string.Format("select ApCode from XXchgcode where ChgCodeId='{0}'", chgCode)));
                        string acSource = "DB";
                        if (docType == "SC")
                        {
                            acSource = "CR";
                        }
                        string  chgDes1     = tab.Rows[0]["ChgDes"].ToString();
                        decimal price       = SafeValue.SafeDecimal(tab.Rows[0]["Price"], 0);
                        string  unit        = tab.Rows[0]["Unit"].ToString().ToUpper();
                        string  currencyDes = tab.Rows[0]["Currency"].ToString();
                        decimal exRateDes   = SafeValue.SafeDecimal(tab.Rows[0]["ExRate"], 0);
                        decimal gst         = SafeValue.SafeDecimal(tab.Rows[0]["Gst"], 0);
                        string  gstType     = tab.Rows[0]["GstType"].ToString();

                        if (qty == 0)
                        {
                            qty = SafeValue.SafeInt(tab.Rows[i]["Qty"], 1);
                        }

                        XAApPayableDet det = new XAApPayableDet();
                        det.AcCode   = acCode;
                        det.AcSource = acSource;
                        det.ChgCode  = chgCode;
                        det.ChgDes1  = chgDes1;
                        det.ChgDes2  = "";
                        det.ChgDes3  = "";
                        det.Currency = currencyDes;
                        det.ExRate   = exRateDes;

                        det.Price = price;
                        det.Qty   = qty;
                        det.Unit  = unit;

                        det.Gst     = gst;
                        det.GstType = gstType;

                        decimal amt    = SafeValue.ChinaRound(qty * price, 2);
                        decimal gstAmt = SafeValue.ChinaRound(amt * gst, 2);
                        decimal docAmt = amt + gstAmt;
                        decimal locAmt = SafeValue.ChinaRound(docAmt * exRateDes, 2);
                        det.GstAmt     = gstAmt;
                        det.DocAmt     = docAmt;
                        det.LocAmt     = locAmt;
                        det.LineLocAmt = 0;
                        det.DocId      = invId;
                        det.DocLineNo  = index;
                        det.DocNo      = invNo;
                        det.DocType    = docType;
                        det.MastRefNo  = refNo;
                        det.JobRefNo   = jobNo;
                        det.MastType   = mastType;
                        det.SplitType  = "SET";
                        C2.Manager.ORManager.StartTracking(det, Wilson.ORMapper.InitialState.Inserted);
                        C2.Manager.ORManager.PersistChanges(det);
                    }
                }
                catch { }
            }
            UpdateApMaster(invId, docType);
        }
        else
        {
            e.Result = "Error, Pls refresh your invoice";
        }
    }
コード例 #7
0
    protected void grid_CustomDataCallback(object sender, ASPxGridViewCustomDataCallbackEventArgs e)
    {
        string s = e.Parameters;

        if (s == "Add")
        {
            string    date    = txt_from.Date.ToString("yyyy-MM-dd");
            string    to      = txt_to.Date.ToString("yyyy-MM-dd");
            string    sql     = string.Format(@"select RefNo,JobDate,JobNo from JobSchedule where CONVERT(VARCHAR(10),JobDate,120) between '{0}' and '{1}'", date, to);
            DataTable tab_job = ConnectSql.GetTab(sql);
            int       res     = 0;
            string    payDate = txt_PayDate.Date.ToString("yyyy-MM-dd");
            if (tab_job.Rows.Count > 0)
            {
                string refNoStr = "";
                for (int m = 0; m < tab_job.Rows.Count; m++)
                {
                    DateTime jobDate = SafeValue.SafeDate(tab_job.Rows[m]["JobDate"], DateTime.Today);
                    string   jobNo   = SafeValue.SafeString(tab_job.Rows[m]["JobNo"]);
                    string   refNo   = SafeValue.SafeString(tab_job.Rows[m]["RefNo"]);
                    sql = string.Format(@"select * from JobCrews where RefNo='{0}' and HrRole='Casual' and IsPay='N'", jobNo);
                    DataTable tab = ConnectSql.GetTab(sql);
                    for (int i = 0; i < tab.Rows.Count; i++)
                    {
                        int    id     = SafeValue.SafeInt(tab.Rows[i]["Id"], 0);
                        string code   = SafeValue.SafeString(tab.Rows[i]["Code"]);
                        string name   = SafeValue.SafeString(tab.Rows[i]["Name"]);
                        string tel    = SafeValue.SafeString(tab.Rows[i]["Tel"]);
                        string hrRole = SafeValue.SafeString(tab.Rows[i]["HrRole"]);
                        string remark = SafeValue.SafeString(tab.Rows[i]["Remark"]);
                        sql = string.Format(@"select count(*) from JobCrews where Remark='{0}' and HrRole='Casual' and Code='{2}' and CONVERT(varchar(100), JobTime, 23)='{1}' and Status='Pay'", remark, jobDate.ToString("yyyy-MM-dd"), code);
                        int cnt = SafeValue.SafeInt(C2.Manager.ORManager.ExecuteScalar(sql), 0);

                        sql = string.Format(@"select HrGroup from Hr_Person where Name='{0}'", name);
                        string type = SafeValue.SafeString(ConnectSql.ExecuteScalar(sql));
                        if (type == "DAY")
                        {
                            if (cnt == 0)
                            {
                                refNoStr = GetJobNo(name, jobDate.ToString("yyyy-MM-dd"));
                                sql      = string.Format(@"select (case when isnull(Amount1,0)=0 then 40 else Amount1 end) as Amount1,
(case when isnull(Amount2,0)=0 then 20 else Amount2 end) as Amount2,
(case when isnull(Amount3,0)=0 then 5 else Amount3 end) as Amount3 from Hr_Person where Name='{0}' and IcNo='{1}'", name, code);
                                DataTable tab_amt = ConnectSql.GetTab(sql);
                                decimal   amt1    = SafeValue.SafeDecimal(tab_amt.Rows[0]["Amount1"]);
                                decimal   amt2    = SafeValue.SafeDecimal(tab_amt.Rows[0]["Amount2"]);
                                decimal   amt3    = SafeValue.SafeDecimal(tab_amt.Rows[0]["Amount3"]);
                                sql = string.Format(@"insert into JobCrews(RefNo,Code,Name,Tel,Status,JobTime,PayDate,IsPay,Amount1,Amount2,Amount3,Amount4,Amount5,Amount6,Amount7,Remark,HrRole) values('{0}','{1}','{2}','{3}','Pay','{4}','{5}','Y',{7},{8},0,0,0,{6},{9},'{10}','{11}')", refNoStr, code, name, tel, jobDate, payDate, amt3, amt1, amt2, (amt1 + amt2), remark, hrRole);
                                res = Manager.ORManager.ExecuteCommand(sql);
                                if (res > 0)
                                {
                                    sql = string.Format(@"update JobCrews set IsPay='Y' where Id={0}", id);
                                    Manager.ORManager.ExecuteCommand(sql);
                                    e.Result = "Success";
                                }
                            }
                            else
                            {
                                sql = string.Format(@"update JobCrews set IsPay='Y' where Id={0}", id);
                                Manager.ORManager.ExecuteCommand(sql);
                            }
                        }
                        if (type == "JOB")
                        {
                            sql      = string.Format(@"select RefNo from JobSchedule where JobNo='{0}'", jobNo);
                            refNoStr = SafeValue.SafeString(ConnectSql.ExecuteScalar(sql));
                            sql      = string.Format(@"select (case when isnull(Amount1,0)=0 then 40 else Amount1 end) as Amount1,
(case when isnull(Amount2,0)=0 then 20 else Amount2 end) as Amount2,
(case when isnull(Amount3,0)=0 then 5 else Amount3 end) as Amount3 from Hr_Person where Name='{0}' and IcNo='{1}'", name, code);
                            DataTable tab_amt = ConnectSql.GetTab(sql);
                            decimal   amt1    = SafeValue.SafeDecimal(tab_amt.Rows[0]["Amount1"]);
                            decimal   amt2    = SafeValue.SafeDecimal(tab_amt.Rows[0]["Amount2"]);
                            decimal   amt3    = SafeValue.SafeDecimal(tab_amt.Rows[0]["Amount3"]);
                            sql = string.Format(@"insert into JobCrews(RefNo,Code,Name,Tel,Status,JobTime,PayDate,IsPay,Amount1,Amount2,Amount3,Amount4,Amount5,Amount6,Amount7,Remark,HrRole) values('{0}','{1}','{2}','{3}','Pay','{4}','{5}','Y',{7},{8},0,0,0,{6},{9},'{10}','{11}')", refNoStr, code, name, tel, jobDate, payDate, amt3, amt1, amt2, (amt1 + amt2), remark, hrRole);
                            res = Manager.ORManager.ExecuteCommand(sql);
                            if (res > 0)
                            {
                                sql = string.Format(@"update JobCrews set IsPay='Y' where Id={0}", id);
                                Manager.ORManager.ExecuteCommand(sql);
                                e.Result = "Success";
                            }
                        }
                    }
                }
            }
            if (tab_job.Rows.Count == 0)
            {
                e.Result = "Fail";
            }
        }
    }
コード例 #8
0
    protected void grid_InvDet_RowInserting(object sender, DevExpress.Web.Data.ASPxDataInsertingEventArgs e)
    {
        ASPxGridView grd        = (sender as ASPxGridView) as ASPxGridView;
        string       sql_detCnt = "select count(DocNo) from XAArReceiptDet where RepId='" + SafeValue.SafeInt(grd.GetMasterRowKeyValue(), 0) + "'";
        int          lineNo     = SafeValue.SafeInt(Manager.ORManager.ExecuteScalar(sql_detCnt), 0) + 1;

        e.NewValues["RepLineNo"] = lineNo;
        e.NewValues["RepId"]     = SafeValue.SafeInt(grd.GetMasterRowKeyValue(), 0);
        ASPxTextBox docN = this.ASPxGridView1.FindEditFormTemplateControl("txt_DocNo") as ASPxTextBox;

        e.NewValues["RepNo"]   = docN.Text;
        e.NewValues["RepType"] = "PC";
        if (SafeValue.SafeDecimal(e.NewValues["ExRate"], 1) == 0)
        {
            e.NewValues["ExRate"] = 1;
        }

        e.NewValues["LocAmt"] = SafeValue.ChinaRound(SafeValue.SafeDecimal(e.NewValues["DocAmt"], 0) * SafeValue.SafeDecimal(e.NewValues["ExRate"], 1), 2);
    }
コード例 #9
0
 protected void grid_InvDet_RowUpdating(object sender, DevExpress.Web.Data.ASPxDataUpdatingEventArgs e)
 {
     if (SafeValue.SafeDecimal(e.NewValues["ExRate"], 1) == 0)
     {
         e.NewValues["ExRate"] = 1;
     }
     e.NewValues["LocAmt"] = SafeValue.ChinaRound(SafeValue.SafeDecimal(e.NewValues["DocAmt"], 0) * SafeValue.SafeDecimal(e.NewValues["ExRate"], 1), 2);
 }
コード例 #10
0
    public static DataTable PrintAuthLetter(string orderNo)
    {
        #region init column
        DataTable mast = new DataTable("Mast");

        mast.Columns.Add("RefN");
        mast.Columns.Add("NowD");
        mast.Columns.Add("Cust");
        mast.Columns.Add("Vend1");
        mast.Columns.Add("BlNo");
        mast.Columns.Add("Sn");
        mast.Columns.Add("Eta");
        mast.Columns.Add("VesVoy");
        mast.Columns.Add("ContNo");
        mast.Columns.Add("FtSize");
        mast.Columns.Add("Port");
        mast.Columns.Add("Ms");
        mast.Columns.Add("Cr");
        mast.Columns.Add("Qty");
        mast.Columns.Add("Wt");
        mast.Columns.Add("M3");
        mast.Columns.Add("SealNo");
        mast.Columns.Add("CompanyName");
        mast.Columns.Add("User");
        mast.Columns.Add("Rmk");
        mast.Columns.Add("Pack");
        #endregion
        string    sql      = string.Format("SELECT JobOrderNo,JobDate,CustCode,Carrier, Eta, VesselNo, VoyNo, Pol,BookingNo,Pod,PermitNo,PartyCode,Haulier FROM XWJobOrder WHERE (JobOrderNo = '{0}')", orderNo);
        DataTable tabOrder = Helper.Sql.List(sql);
        if (tabOrder.Rows.Count == 1)
        {
            string   custCode  = tabOrder.Rows[0]["CustCode"].ToString();
            string   sql1      = "select name from xxparty where partyid='" + custCode + "'";
            string   custName  = SafeValue.SafeString(Helper.Sql.One(sql1), custCode);
            DateTime jobDate   = SafeValue.SafeDate(tabOrder.Rows[0]["JobDate"], DateTime.Today);
            string   ves       = tabOrder.Rows[0]["VesselNo"].ToString();
            string   voy       = tabOrder.Rows[0]["VoyNo"].ToString();
            string   pol       = tabOrder.Rows[0]["Pol"].ToString();
            string   bl        = tabOrder.Rows[0]["BookingNo"].ToString();
            string   pod       = tabOrder.Rows[0]["Pod"].ToString();
            string   carrier   = tabOrder.Rows[0]["Carrier"].ToString();
            string   permitNo  = tabOrder.Rows[0]["PermitNo"].ToString();
            string   partyCode = tabOrder.Rows[0]["PartyCode"].ToString();
            string   haulier   = tabOrder.Rows[0]["Haulier"].ToString();
            sql1 = "select name from [XXPort] where code='" + SafeValue.SafeString(pol, "") + "'";
            string port = "";

            if (pol == "NA")
            {
                port = "NA";
            }
            else
            {
                port = SafeValue.SafeString(Helper.Sql.One(sql1), pol) + " / " + SafeValue.SafeString(Helper.Sql.One(sql1), pod);
            }
            string eta = SafeValue.SafeDateStr(tabOrder.Rows[0]["Eta"]);
            sql1 = string.Format(@"select Name,CrNo from xxParty where PartyId='{0}'", haulier);
            DataTable dt_p = Helper.Sql.List(sql1);
            string    ms   = "";
            string    cr   = "";
            if (dt_p.Rows.Count > 0)
            {
                ms = SafeValue.SafeString(dt_p.Rows[0]["Name"]);
                cr = SafeValue.SafeString(dt_p.Rows[0]["CrNo"]);
            }
            string    contNo  = "";
            string    sealNo  = "";
            int       ft20    = 0;
            int       ft40    = 0;
            int       ft45    = 0;
            int       qty     = 0;
            decimal   wt      = 0;
            decimal   m3      = 0;
            string    ftSize  = "";
            string    ftType  = "";
            string    rmk     = "";
            string    sqlCont = string.Format("SELECT ContNo, SealNo, Ft20, Ft40, Ft45, FtType,Remark FROM XWJobCont WHERE (JobOrder = '{0}')", orderNo);
            DataTable tabCont = Helper.Sql.List(sqlCont);
            if (tabCont.Rows.Count > 0)
            {
                for (int i = 0; i < tabCont.Rows.Count; i++)
                {
                    DataRow row1 = tabCont.Rows[i];
                    contNo = row1["ContNo"].ToString();
                    sealNo = row1["SealNo"].ToString();

                    ft20 = SafeValue.SafeInt(row1["Ft20"], 0);
                    ft40 = SafeValue.SafeInt(row1["Ft40"], 0);
                    ft45 = SafeValue.SafeInt(row1["Ft45"], 0);

                    if (ft20 > 0)
                    {
                        ftSize = "20";
                    }
                    else if (ft40 > 0)
                    {
                        ftSize += "40";
                    }
                    else if (ft45 > 0)
                    {
                        ftSize += "45";
                    }
                    ftType = row1["FtType"].ToString();

                    rmk = row1["Remark"].ToString();
                    string sql_sum = string.Format("SELECT  SUM(QtyOrig) AS Qty, SUM(WeightOrig) AS Wt, SUM(M3Orig) AS M3 FROM  XWJobDet WHERE (JobOrder = '{0}') AND (ContNo = '{1}')", orderNo, contNo);

                    DataTable tab_sum = Helper.Sql.List(sql_sum);
                    if (tab_sum.Rows.Count == 1)
                    {
                        qty = SafeValue.SafeInt(tab_sum.Rows[0]["Qty"], 0);
                        wt  = SafeValue.SafeDecimal(tab_sum.Rows[0]["Wt"], 0);
                        m3  = SafeValue.SafeDecimal(tab_sum.Rows[0]["M3"], 0);
                    }
                }
            }
            DataRow row = mast.NewRow();
            row["Cust"]        = custCode; //custName;
            row["Vend1"]       = carrier;
            row["RefN"]        = orderNo;
            row["NowD"]        = jobDate.ToString("dd/MM/yyyy");
            row["Eta"]         = eta;
            row["VesVoy"]      = ves + "/" + voy;
            row["ContNo"]      = contNo;
            row["FtSize"]      = ftSize + ftType;
            row["Port"]        = port;
            row["Qty"]         = qty;
            row["Wt"]          = wt.ToString("0.000");
            row["M3"]          = m3.ToString("0.000");
            row["SealNo"]      = sealNo;
            row["Rmk"]         = rmk;
            row["BlNo"]        = bl;
            row["Ms"]          = ms;
            row["Cr"]          = cr;
            row["CompanyName"] = System.Configuration.ConfigurationManager.AppSettings["CompanyName"];
            row["Pack"]        = "";
            row["User"]        = HttpContext.Current.User.Identity.Name;
            mast.Rows.Add(row);
        }
        return(mast);
    }
コード例 #11
0
    private void OnLoad()
    {
        int start = 0;
        int end   = 1000;

        for (int i = start; i < end; i++)
        {
            ASPxCheckBox isPay      = this.grid1.FindRowCellTemplateControl(i, (DevExpress.Web.ASPxGridView.GridViewDataColumn) this.grid1.Columns["Id"], "ack_IsPay") as ASPxCheckBox;
            ASPxTextBox  id         = this.grid1.FindRowCellTemplateControl(i, (DevExpress.Web.ASPxGridView.GridViewDataColumn) this.grid1.Columns["Id"], "txt_Id") as ASPxTextBox;
            ASPxSpinEdit spin_Price = this.grid1.FindRowCellTemplateControl(i, (DevExpress.Web.ASPxGridView.GridViewDataColumn) this.grid1.Columns["Price"], "spin_Price") as ASPxSpinEdit;
            ASPxSpinEdit spin_Qty   = this.grid1.FindRowCellTemplateControl(i, (DevExpress.Web.ASPxGridView.GridViewDataColumn) this.grid1.Columns["Qty"], "spin_Qty") as ASPxSpinEdit;
            ASPxTextBox  txt_Unit   = this.grid1.FindRowCellTemplateControl(i, (DevExpress.Web.ASPxGridView.GridViewDataColumn) this.grid1.Columns["Unit"], "txt_Unit") as ASPxTextBox;

            if (id != null && isPay != null && isPay.Checked)
            {
                list.Add(new Record(SafeValue.SafeInt(id.Text, 0), SafeValue.SafeDecimal(spin_Price.Value), SafeValue.SafeDecimal(spin_Qty.Value), txt_Unit.Text));
            }
            else if (id == null)
            {
                break;
            }
        }
    }
コード例 #12
0
    public static DataSet DsImpTs_Pre(string orderNo, string userName)
    {
        DataTable mast    = InitTsMastDataTable();
        DataTable details = InitTsDetailDataTable();

        string    sql_Order = string.Format("select Vessel,Voyage,CarrierBkgNo,EtaDate,ClientContact,ClientRefNo,Pol,PartyId,AdditionalRemark,CreateBy,IssuedBy from ctm_job where JobNo='{0}'", orderNo);
        DataTable tab_Order = Helper.Sql.List(sql_Order);

        if (tab_Order.Rows.Count == 1)
        {
            DataRow row_Order = tab_Order.Rows[0];
            #region tally sheet
            DataRow row = mast.NewRow();
            row["JobOrderNo"] = orderNo;
            row["VesselNo"]   = row_Order["Vessel"];
            row["BookingNo"]  = row_Order["CarrierBkgNo"];
            row["VoyNo"]      = row_Order["Voyage"];


            row["Eta"]      = SafeValue.SafeDateStr(row_Order["EtaDate"]);
            row["ByWho"]    = row_Order["ClientContact"];
            row["ImpRefNo"] = row_Order["ClientRefNo"];
            string sql = "select name from XXPort where Code='" + SafeValue.SafeString(row_Order["Pol"], "") + "'";
            row["PortLoad"]  = SafeValue.SafeString(row_Order["Pol"], ""); //SafeValue.SafeString(Helper.Sql.One(sql), "");
            sql              = "select name from xxparty where partyid='" + row_Order["PartyId"] + "'";
            row["CustName"]  = row_Order["PartyId"];                       //SafeValue.SafeString(Helper.Sql.One(sql), "");
            row["Condition"] = row_Order["AdditionalRemark"];
            row["UserData1"] = row_Order["CreateBy"];
            row["IssueBy"]   = row_Order["IssuedBy"];
            row["UserName"]  = userName;
            mast.Rows.Add(row);

            string    sql_JobDet = string.Format(@"select DoNo,CargoType,ContNo,SealNo,IsDg,BookingNo,HblNo,Marking2
,Qty,UomCode,PackTypeOrig,Volume,Weight,QtyOrig,VolumeOrig,WeightOrig, POD
,Remark1,DgClass,Desc2 from job_house where JobNo='{0}' order by ContNo,LineId,IsDg,DoNo", orderNo);
            DataTable tab_Det    = Helper.Sql.List(sql_JobDet);
            int       g0         = 0;
            int       g1         = 0;
            int       g2         = 0;
            int       p          = 0;
            string    lastContNo = "";

            bool lastDg = false;
            for (int i = 0; i < tab_Det.Rows.Count; i++)
            {
                DataRow row_Det = tab_Det.Rows[i];
                DataRow row1    = details.NewRow();
                string  dnNo    = row_Det["DoNo"].ToString();
                string  jobType = "";
                string  contNo  = row_Det["ContNo"].ToString();
                string  sealNo  = row_Det["SealNo"].ToString();
                bool    isDg    = SafeValue.SafeBool(row_Det["IsDg"], false);
                string  dgClass = row_Det["DgClass"].ToString();
                string  expBkgN = row_Det["BookingNo"].ToString();
                string  hblN    = row_Det["HblNo"].ToString();
                string  mkg     = row_Det["Marking2"].ToString();
                string  rmk     = row_Det["Remark1"].ToString();
                string  desc2   = row_Det["Desc2"].ToString();
                string  pod     = "";

                //int tally1 = SafeValue.SafeInt(row_Det["Tally1"], 0);
                //int tally2 = SafeValue.SafeInt(row_Det["Tally2"], 0);
                //int tally3 = SafeValue.SafeInt(row_Det["Tally3"], 0);
                //int tally4 = SafeValue.SafeInt(row_Det["Tally4"], 0);
                //int tally21 = SafeValue.SafeInt(row_Det["Tally21"], 0);
                //int tally22 = SafeValue.SafeInt(row_Det["Tally22"], 0);
                //int tally23 = SafeValue.SafeInt(row_Det["Tally23"], 0);
                //int tally24 = SafeValue.SafeInt(row_Det["Tally24"], 0);
                //int tally31 = SafeValue.SafeInt(row_Det["Tally31"], 0);
                //int tally32 = SafeValue.SafeInt(row_Det["Tally32"], 0);
                //int tally33 = SafeValue.SafeInt(row_Det["Tally33"], 0);
                //int tally34 = SafeValue.SafeInt(row_Det["Tally34"], 0);
                //int tally41 = SafeValue.SafeInt(row_Det["Tally41"], 0);
                //int tally42 = SafeValue.SafeInt(row_Det["Tally42"], 0);
                //int tally43 = SafeValue.SafeInt(row_Det["Tally43"], 0);
                //int tally44 = SafeValue.SafeInt(row_Det["Tally44"], 0);
                //int tally51 = SafeValue.SafeInt(row_Det["Tally51"], 0);
                //int tally52 = SafeValue.SafeInt(row_Det["Tally52"], 0);
                //int tally53 = SafeValue.SafeInt(row_Det["Tally53"], 0);
                //int tally54 = SafeValue.SafeInt(row_Det["Tally54"], 0);
                //int tally61 = SafeValue.SafeInt(row_Det["Tally61"], 0);
                //int tally62 = SafeValue.SafeInt(row_Det["Tally62"], 0);
                //int tally63 = SafeValue.SafeInt(row_Det["Tally63"], 0);
                //int tally64 = SafeValue.SafeInt(row_Det["Tally64"], 0);

                int     qty      = SafeValue.SafeInt(row_Det["Qty"], 0);
                decimal wt       = SafeValue.SafeDecimal(row_Det["Weight"], 0);
                decimal m3       = SafeValue.SafeDecimal(row_Det["Volume"], 0);
                string  pkgType  = SafeValue.SafeString(row_Det["UomCode"], "");
                string  pkgType2 = SafeValue.SafeString(row_Det["PackTypeOrig"], "");
                int     qtyOrig  = SafeValue.SafeInt(row_Det["QtyOrig"], 0);
                decimal wtOrig   = SafeValue.SafeDecimal(row_Det["WeightOrig"], 0);
                decimal m3Orig   = SafeValue.SafeDecimal(row_Det["VolumeOrig"], 0);

                if ((contNo == lastContNo & isDg == lastDg) || lastContNo == "")
                {
                    g2++;
                }
                else
                {
                    g0++;
                    g1 = 1;
                    g2 = 1;
                    p  = 0;
                }
                lastContNo         = contNo;
                lastDg             = isDg;
                row1["JobOrderNo"] = orderNo;
                p++;
                row1["LineN"] = p;

                row1["PrintGroup"]    = string.Format("C{0:00}{1:00}", g0, g1);
                row1["PrintSesseion"] = string.Format("C{0:00}", g0);
                if (g2 % 6 == 0)
                {
                    g1++;
                }
                row1["ContNo"] = contNo;
                row1["SealNo"] = sealNo;
                //string sql_cont = string.Format("select ContNo,SealNo,Ft20,Ft40,Ft45,FtType,scheduleDate,ScheduleTime,ActualDate,ActualTime,TallyClerk,FlDriver from xwjobcont where JobOrder='{0}' and ContNo='{1}'", orderNo, contNo);
                //DataTable tab_cont = Helper.Sql.List(sql_cont);
                //if (tab_cont.Rows.Count > 0)
                //{
                //    row1["SealNo"] = SafeValue.SafeString(tab_cont.Rows[0]["SealNo"], "");
                //    row1["FtType"] = SafeValue.SafeString(tab_cont.Rows[0]["FtType"], "");
                //    row1["SchDate"] = SafeValue.SafeDateStr(tab_cont.Rows[0]["ScheduleDate"]);
                //    row1["ComplDate"] = SafeValue.SafeDateStr(tab_cont.Rows[0]["ActualDate"]);
                //    string time = SafeValue.SafeString(tab_cont.Rows[0]["ScheduleTime"], "");
                //    string time1 = SafeValue.SafeString(tab_cont.Rows[0]["ActualTime"], "");
                //    if (time.Trim().Length > 0)
                //    {
                //        row1["SchTime"] = time;
                //    }
                //    if (time1.Trim().Length > 0)
                //        row1["ComplTime"] = time1;
                //    string size = "";
                //    if (SafeValue.SafeInt(tab_cont.Rows[0]["Ft20"], 0) > 0)
                //        size = "20";
                //    else if (SafeValue.SafeInt(tab_cont.Rows[0]["Ft40"], 0) > 0)
                //        size = "40";
                //    else if (SafeValue.SafeInt(tab_cont.Rows[0]["Ft45"], 0) > 0)
                //        size = "45";
                //    row1["Size"] = size;
                //    row1["TallyClerk"] = SafeValue.SafeString(tab_cont.Rows[0]["TallyClerk"], "");
                //    row1["Driver"] = SafeValue.SafeString(tab_cont.Rows[0]["FlDriver"], "");
                //}
                row1["DnNO"]       = dnNo.Trim();
                row1["ExpBkgN"]    = expBkgN;
                row1["HblN"]       = hblN;
                row1["TotMarking"] = mkg;

                //row1["Tally1"] = tally1.ToString("#");
                //row1["Tally2"] = tally2.ToString("#");
                //row1["Tally3"] = tally3.ToString("#");
                //row1["Tally4"] = tally4.ToString("#");
                //row1["Tally21"] = tally21.ToString("#");
                //row1["Tally22"] = tally22.ToString("#");
                //row1["Tally23"] = tally23.ToString("#");
                //row1["Tally24"] = tally24.ToString("#");
                //row1["Tally31"] = tally31.ToString("#");
                //row1["Tally32"] = tally32.ToString("#");
                //row1["Tally33"] = tally33.ToString("#");
                //row1["Tally34"] = tally34.ToString("#");
                //row1["Tally41"] = tally41.ToString("#");
                //row1["Tally42"] = tally42.ToString("#");
                //row1["Tally43"] = tally43.ToString("#");
                //row1["Tally44"] = tally44.ToString("#");
                //row1["Tally51"] = tally51.ToString("#");
                //row1["Tally52"] = tally52.ToString("#");
                //row1["Tally53"] = tally53.ToString("#");
                //row1["Tally54"] = tally54.ToString("#");
                //row1["Tally61"] = tally61.ToString("#");
                //row1["Tally62"] = tally62.ToString("#");
                //row1["Tally63"] = tally63.ToString("#");
                //row1["Tally64"] = tally64.ToString("#");
                row1["TotQty"]       = qty.ToString("#");
                row1["PackType"]     = pkgType;
                row1["PackTypeOrig"] = pkgType2;
                row1["M3"]           = m3.ToString("#,##0.000");
                row1["Weight"]       = wt.ToString("#,##0.000");


                row1["OrigQty"]    = qtyOrig.ToString("#");
                row1["OrigM3"]     = m3Orig.ToString("#,##0.000");
                row1["OrigWeight"] = wtOrig.ToString("#,##0.000");
                if (qtyOrig != qty)
                {
                    row1["DiffQty"] = qty - qtyOrig;
                }
                if (m3Orig != m3)
                {
                    row1["DiffM3"] = m3 - m3Orig;
                }
                if (wtOrig != wt)
                {
                    row1["DiffWeight"] = wt - wtOrig;
                }

                row1["TotRemark"]   = rmk;
                row1["LocalRemark"] = "";


                if (isDg)
                {
                    if (dgClass.Trim().Length < 1)
                    {
                        row1["DgClass"] = "DG Cargo";
                    }
                    else
                    {
                        row1["DgClass"] = "DG Class:\n" + dgClass;
                    }
                }
                //row1["TotDesc"] = desc2.Trim();
                row1["POD"] = pod;
                if (jobType.ToUpper() == "T")
                {
                    if (desc2.Trim().Length > 23)
                    {
                        row1["TotDesc"] = desc2.Trim().Substring(desc2.Trim().Length - 23).Trim().Replace("\n", "") + "\n" + rmk.Trim();
                    }
                    else
                    {
                        row1["TotDesc"] = desc2.Trim() + "\n" + rmk.Trim();
                    }

                    // row1["TotDesc"] += "\n\nM3:" + SafeValue.SafeDecimal(row_Det["M3"], 0).ToString("0.000");
                }
                else
                {
                    row1["TotDesc"] = rmk;
                }
                details.Rows.Add(row1);
            }
            #endregion
        }
        DataSet set = new DataSet();
        set.Tables.Add(mast);
        set.Tables.Add(details);
        set.Relations.Add("", mast.Columns["JobOrderNo"], details.Columns["JobOrderNo"]);

        return(set);
    }
コード例 #13
0
ファイル: ArCnEdit.aspx.cs プロジェクト: felix-wei/tsllog1806
    private void SaveAndUpdate()
    {
        ASPxTextBox  invNCtr     = this.ASPxGridView1.FindEditFormTemplateControl("txt_Oid") as ASPxTextBox;
        ASPxComboBox partyTo     = this.ASPxGridView1.FindEditFormTemplateControl("cmb_PartyTo") as ASPxComboBox;
        ASPxTextBox  docN        = this.ASPxGridView1.FindEditFormTemplateControl("txt_DocNo") as ASPxTextBox;
        ASPxComboBox docType     = this.ASPxGridView1.FindEditFormTemplateControl("cbo_DocType") as ASPxComboBox;
        ASPxDateEdit docDate     = this.ASPxGridView1.FindEditFormTemplateControl("txt_DocDt") as ASPxDateEdit;
        ASPxMemo     remarks1    = this.ASPxGridView1.FindEditFormTemplateControl("txt_Remarks1") as ASPxMemo;
        ASPxComboBox termId      = this.ASPxGridView1.FindEditFormTemplateControl("txt_TermId") as ASPxComboBox;
        ASPxDateEdit dueDt       = this.ASPxGridView1.FindEditFormTemplateControl("txt_DueDt") as ASPxDateEdit;
        ASPxTextBox  docCurr     = this.ASPxGridView1.FindEditFormTemplateControl("txt_Currency") as ASPxTextBox;
        ASPxSpinEdit exRate      = this.ASPxGridView1.FindEditFormTemplateControl("txt_DocExRate") as ASPxSpinEdit;
        ASPxTextBox  acCode      = this.ASPxGridView1.FindEditFormTemplateControl("txt_AcCode") as ASPxTextBox;
        ASPxComboBox acSource    = this.ASPxGridView1.FindEditFormTemplateControl("txt_AcSource") as ASPxComboBox;
        ASPxTextBox  specialNote = this.ASPxGridView1.FindEditFormTemplateControl("txt_SpecialNote") as ASPxTextBox;


        ASPxTextBox  mastRefNCtr = this.ASPxGridView1.FindEditFormTemplateControl("txt_MastRefNo") as ASPxTextBox;
        ASPxTextBox  jobRefNCtr  = this.ASPxGridView1.FindEditFormTemplateControl("txt_JobRefNo") as ASPxTextBox;
        ASPxComboBox jobType     = this.ASPxGridView1.FindEditFormTemplateControl("cbo_DocCate") as ASPxComboBox;

        string invN = docN.Text;

        C2.XAArInvoice inv = Manager.ORManager.GetObject(typeof(XAArInvoice), SafeValue.SafeInt(invNCtr.Text, 0)) as XAArInvoice;
        if (inv == null)// first insert invoice
        {
            invN        = C2Setup.GetNextNo("", "AR-CN", docDate.Date);
            inv         = new XAArInvoice();
            inv.PartyTo = SafeValue.SafeString(partyTo.Value, "");
            inv.DocType = docType.Value.ToString();
            inv.DocNo   = invN.ToString();
            inv.DocDate = docDate.Date;
            inv.Term    = termId.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);
            //
            int dueDay = SafeValue.SafeInt(termId.Text.ToUpper().Replace("DAYS", "").Trim(), 0);
            inv.DocDueDate  = inv.DocDate.AddDays(dueDay);//SafeValue.SafeDate(dueDt.Text, DateTime.Now);
            inv.Description = remarks1.Text;
            inv.CurrencyId  = docCurr.Text.ToString();
            inv.ExRate      = SafeValue.SafeDecimal(exRate.Value, 1);
            if (inv.ExRate <= 0)
            {
                inv.ExRate = 1;
            }
            inv.AcCode      = EzshipHelper.GetAccArCode(inv.PartyTo, inv.CurrencyId);
            inv.AcSource    = acSource.Value.ToString();
            inv.SpecialNote = specialNote.Text;

            inv.MastType  = SafeValue.SafeString(jobType.Value, "I");
            inv.MastRefNo = mastRefNCtr.Text;
            inv.JobRefNo  = jobRefNCtr.Text;

            inv.ExportInd  = "N";
            inv.UserId     = HttpContext.Current.User.Identity.Name;
            inv.EntryDate  = DateTime.Now;
            inv.CancelDate = new DateTime(1900, 1, 1);
            inv.CancelInd  = "N";
            try
            {
                C2.Manager.ORManager.StartTracking(inv, Wilson.ORMapper.InitialState.Inserted);
                C2.Manager.ORManager.PersistChanges(inv);
                C2Setup.SetNextNo("", "AR-CN", invN, inv.DocDate);
            }
            catch
            {
            }
        }
        else
        {
            inv.PartyTo = SafeValue.SafeString(partyTo.Value, "");

            inv.Term    = termId.Text;
            inv.DocDate = docDate.Date;
            string[] currentPeriod = EzshipHelper.GetAccPeriod(docDate.Date);

            inv.AcYear   = SafeValue.SafeInt(currentPeriod[1], docDate.Date.Year);
            inv.AcPeriod = SafeValue.SafeInt(currentPeriod[0], docDate.Date.Month);

            int dueDay = SafeValue.SafeInt(termId.Text.ToUpper().Replace("DAYS", "").Trim(), 0);
            inv.DocDueDate  = inv.DocDate.AddDays(dueDay);//SafeValue.SafeDate(dueDt.Text, DateTime.Now);
            inv.Description = remarks1.Text;
            inv.CurrencyId  = docCurr.Text.ToString();
            inv.ExRate      = SafeValue.SafeDecimal(exRate.Value, 1);
            if (inv.ExRate <= 0)
            {
                inv.ExRate = 1;
            }
            inv.AcCode      = EzshipHelper.GetAccArCode(inv.PartyTo, inv.CurrencyId);
            inv.AcSource    = acSource.Text;
            inv.SpecialNote = specialNote.Text;

            inv.MastType  = SafeValue.SafeString(jobType.Value, "I");
            inv.MastRefNo = mastRefNCtr.Text;
            inv.JobRefNo  = jobRefNCtr.Text;
            try
            {
                Manager.ORManager.StartTracking(inv, InitialState.Updated);
                Manager.ORManager.PersistChanges(inv);
                UpdateMaster(inv.SequenceId);
            }
            catch
            {
            }
        }
        Session["SeaCnEditWhere"]         = "Doctype='CN' and DocNo='" + invN + "'";
        this.dsArInvoice.FilterExpression = "Doctype='CN' and DocNo='" + invN + "'";
        if (this.ASPxGridView1.GetRow(0) != null)
        {
            this.ASPxGridView1.StartEdit(0);
        }
    }
コード例 #14
0
ファイル: ArCnEdit.aspx.cs プロジェクト: felix-wei/tsllog1806
    protected void grid_InvDet_RowUpdating(object sender, DevExpress.Web.Data.ASPxDataUpdatingEventArgs e)
    {
        if (SafeValue.SafeString(e.NewValues["AcCode"], "").Length < 1)
        {
            e.Cancel = true;
            throw new Exception("Pls select the charge code");
        }
        if (!e.NewValues["Currency"].Equals("SGD"))
        {
            e.NewValues["GstType"] = "Z";
            e.NewValues["Gst"]     = new decimal(0);
        }
        if (SafeValue.SafeDecimal(e.NewValues["ExRate"], 1) == 0)
        {
            e.NewValues["ExRate"] = 1;
        }

        decimal amt    = SafeValue.ChinaRound(SafeValue.SafeDecimal(e.NewValues["Qty"], 0) * SafeValue.SafeDecimal(e.NewValues["Price"], 0), 2);
        decimal gstAmt = SafeValue.ChinaRound((amt * SafeValue.SafeDecimal(e.NewValues["Gst"], 0)), 2);
        decimal docAmt = amt + gstAmt;
        decimal locAmt = SafeValue.ChinaRound(docAmt * SafeValue.SafeDecimal(e.NewValues["ExRate"], 1), 2);

        e.NewValues["GstAmt"] = gstAmt;
        e.NewValues["DocAmt"] = docAmt;
        e.NewValues["LocAmt"] = locAmt;
        if (SafeValue.SafeString(e.NewValues["JobRefNo"]).Length > 1)
        {
            e.NewValues["SplitType"] = "SET";
        }
    }
コード例 #15
0
    protected void grid_InvDet_RowUpdating(object sender, DevExpress.Web.Data.ASPxDataUpdatingEventArgs e)
    {
        ASPxTextBox billN  = this.ASPxGridView1.FindEditFormTemplateControl("txt_SupplierBillNo") as ASPxTextBox;
        string      billNo = S.Text(billN.Text).Trim();

        if (!e.NewValues["Currency"].Equals("SGD"))
        {
            e.NewValues["GstType"] = "Z";
            e.NewValues["Gst"]     = new decimal(0);
        }
        if (SafeValue.SafeDecimal(e.NewValues["ExRate"], 1) == 0)
        {
            e.NewValues["ExRate"] = 1;
        }

        decimal amt    = SafeValue.ChinaRound(SafeValue.SafeDecimal(e.NewValues["Qty"], 0) * SafeValue.SafeDecimal(e.NewValues["Price"], 0), 2);
        decimal gstAmt = SafeValue.ChinaRound((amt * SafeValue.SafeDecimal(e.NewValues["Gst"], 0)), 2);
        decimal docAmt = amt + gstAmt;
        decimal locAmt = SafeValue.ChinaRound(docAmt * SafeValue.SafeDecimal(e.NewValues["ExRate"], 1), 2);

        e.NewValues["GstAmt"] = gstAmt;
        e.NewValues["DocAmt"] = docAmt;
        e.NewValues["LocAmt"] = locAmt;

        string _jobno  = S.Text(e.NewValues["MastRefNo"]).Trim();
        string _contno = S.Text(e.NewValues["JobRefNo"]).Trim();

        e.NewValues["MastRefNo"] = _jobno;
        e.NewValues["JobRefNo"]  = _contno;

        if (_jobno.Length > 5 && _contno.Length > 5)
        {
            string sqlPsa = string.Format("update psa_bill set Job_No='{0}' where [Bill Number]='{1}' and [Bill Item Number]='{2}' and [Container Number]='{3}'",
                                          _jobno, billNo, e.NewValues["DocLineNo"],
                                          _contno
                                          );
            //throw new Exception(sqlPsa);
            D.Exec(sqlPsa);
        }
    }
コード例 #16
0
    protected void ASPxGridView1_CustomDataCallback(object sender, ASPxGridViewCustomDataCallbackEventArgs e)
    {
        string      filter = e.Parameters;
        ASPxTextBox oidCtr = this.ASPxGridView1.FindEditFormTemplateControl("txt_Oid") as ASPxTextBox;

        //get informations from arinvoice
        if (filter == "P")
        {
            #region Post
            string sql = @"SELECT AcYear, AcPeriod, DocType, DocNo, DocDate, DocCurrency, DocExRate, PartyTo, DocAmt, LocAmt, AcCode, AcSource, ChqNo, ChqDate, ExportInd, 
                      BankName, Remark FROM XAArReceipt";
            sql += " WHERE SequenceId='" + oidCtr.Text + "'";
            DataTable dt       = Helper.Sql.List(sql);
            int       acYear   = 0;
            int       acPeriod = 0;
            string    docN     = "";
            string    docType  = "";
            string    acSource = "";
            string    acCode   = "";
            decimal   locAmt   = 0;
            decimal   docAmt   = 0;
            decimal   exRate   = 0;
            string    currency = "";
            DateTime  docDt    = DateTime.Today;
            string    remarks  = "";
            string    partyTo  = "";
            string    chqNo    = "";
            if (dt.Rows.Count == 1)
            {
                acYear   = SafeValue.SafeInt(dt.Rows[0]["AcYear"], 0);
                acPeriod = SafeValue.SafeInt(dt.Rows[0]["AcPeriod"], 0);
                acSource = dt.Rows[0]["AcSource"].ToString();
                acCode   = dt.Rows[0]["AcCode"].ToString();
                docN     = dt.Rows[0]["DocNo"].ToString();
                docType  = dt.Rows[0]["DocType"].ToString();
                locAmt   = SafeValue.SafeDecimal(dt.Rows[0]["LocAmt"].ToString(), 0);
                docAmt   = SafeValue.SafeDecimal(dt.Rows[0]["DocAmt"].ToString(), 0);
                exRate   = SafeValue.SafeDecimal(dt.Rows[0]["DocExRate"].ToString(), 0);
                currency = dt.Rows[0]["DocCurrency"].ToString();
                docDt    = SafeValue.SafeDate(dt.Rows[0]["DocDate"], new DateTime(1900, 1, 1));
                // partyId = dt.Rows[0][""].ToString();
                remarks = dt.Rows[0]["Remark"].ToString();
                partyTo = dt.Rows[0]["PartyTo"].ToString();
                chqNo   = dt.Rows[0]["ChqNo"].ToString();
            }
            else
            {
                e.Result = "Can't find the Bill!";
                return;
            }
            string sqlDet = string.Format("select count(SequenceId) from XAArReceiptDet where RepId='{0}'", oidCtr.Text);
            int    detCnt = SafeValue.SafeInt(Manager.ORManager.ExecuteScalar(sqlDet), 0);
            if (detCnt == 0)
            {
                e.Result = "No Detail, Can't Post";
                return;
            }
            sqlDet = string.Format("select max(docDate) from XAArReceiptDet where RepId='{0}'", oidCtr.Text);
            DateTime maxLineDocDate = SafeValue.SafeDate(Manager.ORManager.ExecuteScalar(sqlDet), new DateTime(1900, 1, 1));
            if (maxLineDocDate > new DateTime(2000, 1, 1) && maxLineDocDate > docDt)
            {
                e.Result = "The bill's Date can't be greater than receipt date.";
                return;
            }

            //check account period
            if (acYear < 1 || acPeriod < 1)
            {
                e.Result = "Account year or Period Invalid!";
                return;
            }
            string sql1     = "select CloseInd from XXAccPeriod where Year='" + acYear + "' and Period ='" + acPeriod + "'";
            string closeInd = SafeValue.SafeString(Manager.ORManager.ExecuteScalar(sql1), "");
            if (closeInd == "")
            {
                e.Result = "Can't find this account period!";
                return;
            }
            else if (closeInd == "Y")
            {
                e.Result = "The account period is closed!";
                return;
            }
            //mast.amt det.amt is match
            //sql = string.Format("select sum(locamt) from XAArReceiptDet where RepId='{0}'", oidCtr.Text);
            //decimal amt_det = SafeValue.SafeDecimal(Manager.ORManager.ExecuteScalar(sql), 0);

            sql = string.Format("select sum(locamt) from XAArReceiptDet where RepId='{0}' and AcSource='CR'", oidCtr.Text);
            decimal amt_detCr = SafeValue.SafeDecimal(Manager.ORManager.ExecuteScalar(sql), 0);
            sql = string.Format("select sum(locamt) from XAArReceiptDet where RepId='{0}' and AcSource='DB'", oidCtr.Text);
            decimal amt_detDb = SafeValue.SafeDecimal(Manager.ORManager.ExecuteScalar(sql), 0);

            if (locAmt != amt_detDb - amt_detCr)
            {
                e.Result = "Amount can't match, can't post";
                return;
            }
            sql    = "select count(*) from XAArReceiptDet where AcCode='' and RepId='" + oidCtr.Text + "'";
            detCnt = SafeValue.SafeInt(C2.Manager.ORManager.ExecuteScalar(sql), 0);
            if (detCnt > 0)
            {
                e.Result = "Some Item's Accode is blank, pls check";
                return;
            }
            //delete old post data
            sql = string.Format("SELECT SequenceId from XAGlEntry WHERE DocNo='{0}' and DocType='{1}'", docN, docType);
            int glOldOid = SafeValue.SafeInt(Manager.ORManager.ExecuteScalar(sql), 0);
            if (glOldOid > 0)
            {
                DeleteGl(glOldOid);
            }

            //Insert into gl entry
            int glOid = 0;
            try
            {
                C2.XAGlEntry gl = new XAGlEntry();
                gl.AcPeriod         = acPeriod;
                gl.AcYear           = acYear;
                gl.ArApInd          = "AR";
                gl.DocType          = docType;
                gl.DocDate          = docDt;
                gl.DocNo            = docN;
                gl.CrAmt            = docAmt;
                gl.DbAmt            = docAmt;
                gl.CurrencyCrAmt    = locAmt;
                gl.CurrencyDbAmt    = locAmt;
                gl.CurrencyId       = currency;
                gl.EntryDate        = DateTime.Now;
                gl.ExRate           = exRate;
                gl.PostDate         = DateTime.Now;
                gl.PostInd          = "N";
                gl.Remark           = remarks;
                gl.UserId           = HttpContext.Current.User.Identity.Name;
                gl.CancelInd        = "N";
                gl.CancelDate       = new DateTime(1900, 1, 1);
                gl.PartyTo          = partyTo;
                gl.ChqNo            = chqNo;
                gl.SupplierBillNo   = "";
                gl.SupplierBillDate = new DateTime(1900, 1, 1);
                Manager.ORManager.StartTracking(gl, InitialState.Inserted);
                Manager.ORManager.PersistChanges(gl);
                glOid = gl.SequenceId;

                //insert Detail
                OPathQuery   query = new OPathQuery(typeof(XAArReceiptDet), "RepId='" + oidCtr.Text + "'");
                ObjectSet    set   = Manager.ORManager.GetObjectSet(query);
                int          index = 1;
                XAGlEntryDet det1  = new XAGlEntryDet();

                det1.AcCode        = acCode;
                det1.ArApInd       = "AR";
                det1.AcPeriod      = acPeriod;
                det1.AcSource      = acSource;
                det1.AcYear        = acYear;
                det1.CrAmt         = docAmt;
                det1.CurrencyCrAmt = locAmt;
                det1.DbAmt         = 0;
                det1.CurrencyDbAmt = 0;
                det1.CurrencyId    = currency;
                det1.DocNo         = docN;
                det1.DocType       = docType;
                det1.ExRate        = exRate;
                det1.GlLineNo      = index;
                det1.GlNo          = gl.SequenceId;
                det1.Remark        = remarks;


                Manager.ORManager.StartTracking(det1, InitialState.Inserted);
                Manager.ORManager.PersistChanges(det1);
                for (int i = 0; i < set.Count; i++)
                {
                    try
                    {
                        index++;
                        XAArReceiptDet invDet = set[i] as XAArReceiptDet;
                        XAGlEntryDet   det    = new XAGlEntryDet();

                        det.AcCode   = invDet.AcCode;
                        det.ArApInd  = "AR";
                        det.AcPeriod = acPeriod;
                        det.AcSource = invDet.AcSource;
                        det.AcYear   = acYear;
                        if (invDet.AcSource == "DB")
                        {
                            det.DbAmt         = invDet.DocAmt;
                            det.CurrencyDbAmt = invDet.LocAmt;
                            det.CrAmt         = 0;
                            det.CurrencyCrAmt = 0;
                        }
                        else //if (det.AcSource == "CR")
                        {
                            det.CrAmt         = invDet.DocAmt;
                            det.CurrencyCrAmt = invDet.LocAmt;
                            det.DbAmt         = 0;
                            det.CurrencyDbAmt = 0;
                        }
                        det.CurrencyId = invDet.Currency;

                        det.DocNo    = docN;
                        det.DocType  = docType;
                        det.ExRate   = invDet.ExRate;
                        det.GlLineNo = index;
                        det.GlNo     = gl.SequenceId;
                        det.Remark   = invDet.Remark1;


                        Manager.ORManager.StartTracking(det, InitialState.Inserted);
                        Manager.ORManager.PersistChanges(det);
                    }
                    catch
                    {
                        e.Result = "Posting Error, Please repost!";
                        DeleteGl(glOid);
                    }
                }
                UpdateArInv(oidCtr.Text);
                e.Result = "Post completely!";
            }
            catch
            {
                e.Result = "Posting Error, Please repost!";
                DeleteGl(glOid);
            }
            #endregion
        }
        else if (filter == "DD")
        {
            #region delete receipt

            try
            {
                string    sql = "SELECT SequenceId,DocId, DocType FROM XAArReceiptDet where RepId ='" + oidCtr.Text + "'";
                DataTable tab = Helper.Sql.List(sql);
                for (int i = 0; i < tab.Rows.Count; i++)
                {
                    try
                    {
                        string sequenceId = tab.Rows[i]["SequenceId"].ToString();
                        string docId      = tab.Rows[i]["DocId"].ToString();
                        string docType    = tab.Rows[i]["DocType"].ToString();
                        string sql_det    = "delete from XAArReceiptDet where SequenceId='" + sequenceId + "'";
                        if (C2.Manager.ORManager.ExecuteCommand(sql_det) > 0)
                        {
                            UpdateMaster(docId);
                        }
                    }
                    catch (Exception ex)
                    {
                        throw new Exception(ex.Message);
                    }
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            #endregion
        }
        else if (filter == "GainLoss")
        {
            #region gain lose
            string  sql    = string.Format("select sum(case when AcSource='DB' then -LocAmt else LocAmt end) As LocAmt from xaarreceiptdet where repid='{0}'", oidCtr.Text);
            decimal balAmt = SafeValue.SafeDecimal(C2.Manager.ORManager.ExecuteScalar(sql), 0);
            if (balAmt > 0)
            {
                string         gainAccCode = System.Configuration.ConfigurationManager.AppSettings["GainLoseAcCode"];
                XAArReceiptDet det         = new XAArReceiptDet();
                det.AcCode   = gainAccCode;
                det.AcSource = "DB";
                det.Currency = System.Configuration.ConfigurationManager.AppSettings["Currency"];
                det.DocAmt   = balAmt;
                det.DocDate  = new DateTime(1900, 1, 1);
                det.DocId    = 0;
                det.DocNo    = "";
                det.DocType  = "PC";
                det.ExRate   = 1;
                det.LocAmt   = balAmt;
                det.Remark1  = "GAIN AND LOSS";
                det.Remark2  = "";
                det.Remark3  = "";
                det.RepId    = SafeValue.SafeInt(oidCtr.Text, 0);
                ASPxTextBox docN = this.ASPxGridView1.FindEditFormTemplateControl("txt_DocNo") as ASPxTextBox;
                det.RepNo = docN.Text;
                string sql_detCnt = "select count(DocNo) from XAArReceiptDet where RepId='" + oidCtr.Text + "'";
                int    lineNo     = SafeValue.SafeInt(Manager.ORManager.ExecuteScalar(sql_detCnt), 0) + 1;
                det.RepLineNo = lineNo;
                det.RepType   = "PC";
                C2.Manager.ORManager.StartTracking(det, Wilson.ORMapper.InitialState.Inserted);
                C2.Manager.ORManager.PersistChanges(det);
            }
            else if (balAmt < 0)
            {
                string         gainAccCode = System.Configuration.ConfigurationManager.AppSettings["GainLoseAcCode"];
                XAArReceiptDet det         = new XAArReceiptDet();
                det.AcCode   = gainAccCode;
                det.AcSource = "CR";
                det.Currency = System.Configuration.ConfigurationManager.AppSettings["Currency"];
                det.DocAmt   = -balAmt;
                det.DocDate  = new DateTime(1900, 1, 1);
                det.DocId    = 0;
                det.DocNo    = "";
                det.DocType  = "PC";
                det.ExRate   = 1;
                det.LocAmt   = -balAmt;
                det.Remark1  = "GAIN AND LOSS";
                det.Remark2  = "";
                det.Remark3  = "";
                det.RepId    = SafeValue.SafeInt(oidCtr.Text, 0);
                ASPxTextBox docN = this.ASPxGridView1.FindEditFormTemplateControl("txt_DocNo") as ASPxTextBox;
                det.RepNo = docN.Text;
                string sql_detCnt = "select count(DocNo) from XAArReceiptDet where RepId='" + oidCtr.Text + "'";
                int    lineNo     = SafeValue.SafeInt(Manager.ORManager.ExecuteScalar(sql_detCnt), 0) + 1;
                det.RepLineNo = lineNo;
                det.RepType   = "PC";
                C2.Manager.ORManager.StartTracking(det, Wilson.ORMapper.InitialState.Inserted);
                C2.Manager.ORManager.PersistChanges(det);
            }
            #endregion
        }
    }
コード例 #17
0
    protected void ASPxGridView1_CustomDataCallback1(object sender, ASPxGridViewCustomDataCallbackEventArgs e)
    {
        string      p      = e.Parameters;
        ASPxTextBox oidCtr = this.ASPxGridView1.FindEditFormTemplateControl("txt_Oid") as ASPxTextBox;

        //get informations from arinvoice
        if (p.ToUpper() == "P")
        {
            #region Post
            string sql = @"SELECT AcYear, AcPeriod, AcCode, AcSource, DocType, DocNo, DocDate, PartyTo, MastType, CurrencyId, ExRate, Term, Description, LocAmt, 
                      DocAmt,SupplierBillNo, SupplierBillDate FROM XAApPayable";
            sql += " WHERE SequenceId='" + oidCtr.Text + "'";
            DataTable dt               = Helper.Sql.List(sql);
            int       acYear           = 0;
            int       acPeriod         = 0;
            string    docN             = "";
            string    docType          = "";
            string    acSource         = "";
            string    acCode           = "";
            decimal   locAmt           = 0;
            decimal   docAmt           = 0;
            decimal   exRate           = 0;
            string    currency         = "";
            string    partyTo          = "";
            string    supplierBillNo   = "";
            DateTime  supplierBillDate = new DateTime(1900, 1, 1);
            DateTime  docDt            = DateTime.Today;
            string    remarks          = "";
            if (dt.Rows.Count == 1)
            {
                acYear   = SafeValue.SafeInt(dt.Rows[0]["AcYear"], 0);
                acPeriod = SafeValue.SafeInt(dt.Rows[0]["AcPeriod"], 0);
                acSource = dt.Rows[0]["AcSource"].ToString();
                acCode   = dt.Rows[0]["AcCode"].ToString();
                docN     = dt.Rows[0]["DocNo"].ToString();
                docType  = dt.Rows[0]["DocType"].ToString();
                locAmt   = SafeValue.SafeDecimal(dt.Rows[0]["LocAmt"].ToString(), 0);
                docAmt   = SafeValue.SafeDecimal(dt.Rows[0]["DocAmt"].ToString(), 0);
                exRate   = SafeValue.SafeDecimal(dt.Rows[0]["ExRate"].ToString(), 0);
                currency = dt.Rows[0]["CurrencyId"].ToString();
                docDt    = SafeValue.SafeDate(dt.Rows[0]["DocDate"], new DateTime(1900, 1, 1));
                // partyId = dt.Rows[0][""].ToString();
                remarks          = dt.Rows[0]["Description"].ToString();
                partyTo          = dt.Rows[0]["PartyTo"].ToString();
                supplierBillNo   = dt.Rows[0]["SupplierBillNo"].ToString();
                supplierBillDate = SafeValue.SafeDate(dt.Rows[0]["SupplierBillDate"], new DateTime(1900, 1, 1));
            }
            else
            {
                e.Result = "Can't find the Payable!";
                return;
            }

            string sqlDet = string.Format("select count(SequenceId) from XAApPayableDet where DocId='{0}'", oidCtr.Text);
            int    detCnt = SafeValue.SafeInt(Manager.ORManager.ExecuteScalar(sqlDet), 0);
            if (detCnt == 0)
            {
                e.Result = "No Detail, Can't Post";
                return;
            }

            //check account period
            if (acYear < 1 || acPeriod < 1)
            {
                e.Result = "Account year or Period Invalid!";
                return;
            }

            string sql1     = "select CloseInd from XXAccPeriod where Year='" + acYear + "' and Period ='" + acPeriod + "'";
            string closeInd = SafeValue.SafeString(Manager.ORManager.ExecuteScalar(sql1), "");
            if (closeInd == "")
            {
                e.Result = "Can't find this account period!";
                return;
            }
            else if (closeInd == "Y")
            {
                e.Result = "The account period is closed!";
                return;
            }

            sql = "select SUM(LocAmt) from XAApPayableDet where AcSource='DB' and DocId='" + oidCtr.Text + "'";
            decimal amt_det = SafeValue.SafeDecimal(C2.Manager.ORManager.ExecuteScalar(sql), 0);
            sql      = "select SUM(LocAmt) from XAApPayableDet where AcSource='CR' and DocId='" + oidCtr.Text + "'";
            amt_det -= SafeValue.SafeDecimal(C2.Manager.ORManager.ExecuteScalar(sql), 0);
            if (docType == "SC")
            {
                amt_det = -amt_det;
            }

            if (docAmt != amt_det)
            {
                e.Result = "Amount can't match, can't post,Please first resave it,";
                return;
            }
            sql    = "select count(LocAmt) from XAApPayableDet where AcCode='' and DocId='" + oidCtr.Text + "'";
            detCnt = SafeValue.SafeInt(C2.Manager.ORManager.ExecuteScalar(sql), 0);
            if (detCnt > 0)
            {
                e.Result = "Some Item's Accode is blank, pls check";
                return;
            }

            //delete old post data
            sql = string.Format("SELECT SequenceId from XAGlEntry WHERE DocNo='{0}' and DocType='{1}'", docN, docType);
            int glOldOid = SafeValue.SafeInt(Manager.ORManager.ExecuteScalar(sql), 0);
            if (glOldOid > 0)
            {
                DeleteGl(glOldOid);
            }

            //Insert into gl entry
            int glOid = 0;
            try
            {
                C2.XAGlEntry gl = new XAGlEntry();
                gl.AcPeriod         = acPeriod;
                gl.AcYear           = acYear;
                gl.ArApInd          = "AP";
                gl.DocType          = docType;
                gl.DocDate          = docDt;
                gl.DocNo            = docN;
                gl.CrAmt            = docAmt;
                gl.DbAmt            = docAmt;
                gl.CurrencyCrAmt    = locAmt;
                gl.CurrencyDbAmt    = locAmt;
                gl.CurrencyId       = currency;
                gl.EntryDate        = DateTime.Now;
                gl.ExRate           = exRate;
                gl.PostDate         = DateTime.Now;
                gl.PostInd          = "N";
                gl.Remark           = remarks;
                gl.UserId           = HttpContext.Current.User.Identity.Name;
                gl.CancelInd        = "N";
                gl.CancelDate       = new DateTime(1900, 1, 1);
                gl.PartyTo          = partyTo;
                gl.ChqNo            = "";
                gl.SupplierBillNo   = supplierBillNo;
                gl.SupplierBillDate = supplierBillDate;
                Manager.ORManager.StartTracking(gl, InitialState.Inserted);
                Manager.ORManager.PersistChanges(gl);
                glOid = gl.SequenceId;
                //insert Detail
                OPathQuery   query = new OPathQuery(typeof(XAApPayableDet), "DocId='" + oidCtr.Text + "'");
                ObjectSet    set   = Manager.ORManager.GetObjectSet(query);
                int          index = 1;
                XAGlEntryDet det1  = new XAGlEntryDet();

                det1.AcCode   = acCode;
                det1.ArApInd  = "AP";
                det1.AcPeriod = acPeriod;
                det1.AcSource = acSource;
                det1.AcYear   = acYear;
                if (docType == "SC")
                {
                    det1.CrAmt         = 0;
                    det1.CurrencyCrAmt = 0;
                    det1.DbAmt         = docAmt;
                    det1.CurrencyDbAmt = locAmt;
                }
                else
                {
                    det1.CrAmt         = docAmt;
                    det1.CurrencyCrAmt = locAmt;
                    det1.DbAmt         = 0;
                    det1.CurrencyDbAmt = 0;
                }
                det1.CurrencyId = currency;
                det1.DocNo      = docN;
                det1.DocType    = docType;
                det1.ExRate     = exRate;
                det1.GlLineNo   = index;
                det1.GlNo       = gl.SequenceId;
                det1.Remark     = remarks;


                Manager.ORManager.StartTracking(det1, InitialState.Inserted);
                Manager.ORManager.PersistChanges(det1);
                decimal gstCrAmt = 0;
                decimal gstDbAmt = 0;
                string  gstAcc   = SafeValue.SafeString(Manager.ORManager.ExecuteScalar("SELECT AcCode FROM XXGstAccount where GstSrc='AP'"), "4053");
                for (int i = 0; i < set.Count; i++)
                {
                    try
                    {
                        index++;
                        XAApPayableDet invDet = set[i] as XAApPayableDet;
                        XAGlEntryDet   det    = new XAGlEntryDet();

                        if (invDet.AcCode == gstAcc)
                        {
                            if (invDet.AcSource == "DB")
                            {
                                gstDbAmt += invDet.LocAmt;
                            }
                            else
                            {
                                gstCrAmt += invDet.LocAmt;
                            }
                        }
                        else
                        {
                            det.AcCode   = invDet.AcCode;
                            det.ArApInd  = "AP";
                            det.AcPeriod = acPeriod;
                            det.AcSource = invDet.AcSource;
                            det.AcYear   = acYear;
                            if (det.AcSource == "CR")
                            {
                                det.CrAmt         = SafeValue.ChinaRound(SafeValue.ChinaRound(invDet.Qty * invDet.Price, 2) * invDet.ExRate, 2);
                                det.CurrencyCrAmt = SafeValue.ChinaRound(det.CrAmt * exRate, 2);
                                det.DbAmt         = 0;
                                det.CurrencyDbAmt = 0;
                                gstCrAmt         += invDet.GstAmt;
                            }
                            else
                            {
                                det.CrAmt         = 0;
                                det.CurrencyCrAmt = 0;
                                det.DbAmt         = SafeValue.ChinaRound(SafeValue.ChinaRound(invDet.Qty * invDet.Price, 2) * invDet.ExRate, 2);
                                det.CurrencyDbAmt = SafeValue.ChinaRound(det.DbAmt * exRate, 2);
                                gstDbAmt         += invDet.GstAmt;
                            }
                            det.CurrencyId = invDet.Currency;
                            det.DocNo      = docN;
                            det.DocType    = docType;
                            det.ExRate     = invDet.ExRate;
                            det.GlLineNo   = index;
                            det.GlNo       = gl.SequenceId;
                            det.Remark     = invDet.ChgCode;

                            Manager.ORManager.StartTracking(det, InitialState.Inserted);
                            Manager.ORManager.PersistChanges(det);
                        }
                    }
                    catch
                    {
                        e.Result = "Posting Error, Please repost!";
                        DeleteGl(glOid);
                    }
                }
                if (gstDbAmt - gstCrAmt != 0)
                {
                    XAGlEntryDet det = new XAGlEntryDet();
                    det.AcCode   = gstAcc;
                    det.ArApInd  = "AP";
                    det.AcPeriod = acPeriod;
                    det.AcYear   = acYear;
                    if (docType == "SC")
                    {
                        det.AcSource      = "CR";
                        det.CrAmt         = gstCrAmt - gstDbAmt;
                        det.CurrencyCrAmt = gstCrAmt - gstDbAmt;
                        det.DbAmt         = 0;
                        det.CurrencyDbAmt = 0;
                    }
                    else
                    {
                        det.AcSource      = "DB";
                        det.CrAmt         = 0;
                        det.CurrencyCrAmt = 0;
                        det.CurrencyDbAmt = gstDbAmt - gstCrAmt;
                        det.DbAmt         = gstDbAmt - gstCrAmt;
                    }

                    det.CurrencyId = System.Configuration.ConfigurationManager.AppSettings["Currency"];
                    det.DocNo      = docN;
                    det.DocType    = docType;
                    det.ExRate     = 1;
                    det.GlLineNo   = index + 1;
                    det.GlNo       = gl.SequenceId;
                    det.Remark     = "GST";

                    Manager.ORManager.StartTracking(det, InitialState.Inserted);
                    Manager.ORManager.PersistChanges(det);
                }
                UpdateArInv(oidCtr.Text);
                e.Result = "Post completely!";
            }
            catch
            {
                e.Result = "Posting Error, Please repost!";
                DeleteGl(glOid);
            }
            #endregion
        }
        else if (p == "V")
        {
            string sql = string.Format(@"SELECT  count(*) FROM XAApPaymentDet WHERE (DocId = '{0}')", oidCtr.Text);
            int    cnt = SafeValue.SafeInt(Manager.ORManager.ExecuteScalar(sql), 0);
            if (cnt > 0)
            {
                e.Result = "Have Pay this bill, can't void it.";
                return;
            }
            else
            {
                sql = string.Format("update XAApPayable set CancelInd='Y',Description=Description+' Void by {1}' where Sequenceid='{0}'", oidCtr.Text, HttpContext.Current.User.Identity.Name);
                int res = Manager.ORManager.ExecuteCommand(sql);
                if (res > 0)
                {
                    e.Result = "Success";
                }
                else
                {
                    e.Result = "Fail";
                }
            }
        }
    }
コード例 #18
0
    protected void ASPxGridView1_CustomCallback(object sender, DevExpress.Web.ASPxGridView.ASPxGridViewCustomCallbackEventArgs e)
    {
        ASPxTextBox oidCtr = this.ASPxGridView1.FindEditFormTemplateControl("txt_Oid") as ASPxTextBox;
        //ASPxTextBox acYear = this.ASPxGridView1.FindEditFormTemplateControl("txt_AcYear") as ASPxTextBox;
        //ASPxTextBox acPeriod = this.ASPxGridView1.FindEditFormTemplateControl("txt_AcPeriod") as ASPxTextBox;
        //ASPxTextBox party = this.ASPxGridView1.FindEditFormTemplateControl("txt_PartyCode") as ASPxTextBox;
        ASPxComboBox partyTo = this.ASPxGridView1.FindEditFormTemplateControl("cmb_PartyTo") 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;

        ASPxTextBox  docCurr = this.ASPxGridView1.FindEditFormTemplateControl("txt_Currency") as ASPxTextBox;
        ASPxSpinEdit exRate  = this.ASPxGridView1.FindEditFormTemplateControl("txt_DocExRate") as ASPxSpinEdit;
        ASPxTextBox  acCode  = this.ASPxGridView1.FindEditFormTemplateControl("txt_AcCode") 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;

        ASPxSpinEdit docAmt = this.ASPxGridView1.FindEditFormTemplateControl("spin_DocAmt") as ASPxSpinEdit;

        C2.XAArReceipt inv   = Manager.ORManager.GetObject(typeof(XAArReceipt), SafeValue.SafeInt(oidCtr.Text, 0)) as XAArReceipt;
        bool           isNew = false;

        if (null == inv)// first insert invoice
        {
            isNew = true;
            string invN = C2Setup.GetNextNo("AR-PC");
            inv             = new C2.XAArReceipt();
            inv.PartyTo     = SafeValue.SafeString(partyTo.Value, "");
            inv.DocNo       = invN;
            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.AcSource  = acDorc.Text;
            inv.BankName  = bankName.Text;
            inv.ChqNo     = chqNo.Text;
            inv.ExportInd = "N";
            inv.DocType   = "PC";
            inv.DocType1  = "Refund";
            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);
            string[] currentPeriod = EzshipHelper.GetAccPeriod(docDate.Date);
            inv.AcYear   = SafeValue.SafeInt(currentPeriod[1], docDate.Date.Year);
            inv.AcPeriod = SafeValue.SafeInt(currentPeriod[0], docDate.Date.Month);
            try
            {
                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);
                C2Setup.SetNextNo("AR-PC", 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.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);

            try
            {
                inv.UpdateBy       = HttpContext.Current.User.Identity.Name;
                inv.UpdateDateTime = DateTime.Now;
                Manager.ORManager.StartTracking(inv, InitialState.Updated);
                Manager.ORManager.PersistChanges(inv);
            }
            catch
            { }
        }
        if (isNew)
        {
            Session["PcEditWhere"]            = "SequenceId=" + inv.SequenceId;
            this.dsArReceipt.FilterExpression = Session["PcEditWhere"].ToString();
            if (this.ASPxGridView1.GetRow(0) != null)
            {
                this.ASPxGridView1.StartEdit(0);
            }
        }
    }
コード例 #19
0
    private void Trip_Update(object sender, ASPxGridViewCustomDataCallbackEventArgs e)
    {
        ASPxGridView grd       = sender as ASPxGridView;
        ASPxLabel    lb_tripId = grd.FindEditFormTemplateControl("lb_tripId") as ASPxLabel;
        string       tripId    = SafeValue.SafeString(lb_tripId.Text, "");

        Wilson.ORMapper.OPathQuery query = new Wilson.ORMapper.OPathQuery(typeof(C2.CtmJobDet2), "Id='" + tripId + "'");;
        C2.CtmJobDet2 trip       = C2.Manager.ORManager.GetObject(query) as C2.CtmJobDet2;
        string        Driver_old = "";

        bool isNew = false;

        if (trip == null)
        {
            isNew = true;
            trip  = new C2.CtmJobDet2();
        }
        else
        {
            Driver_old = trip.DriverCode;
        }

        ASPxDropDownEdit dde_Trip_ContNo = grd.FindEditFormTemplateControl("dde_Trip_ContNo") as ASPxDropDownEdit;
        ASPxTextBox      dde_Trip_ContId = grd.FindEditFormTemplateControl("dde_Trip_ContId") as ASPxTextBox;
        //ASPxButtonEdit btn_CfsCode = grd.FindEditFormTemplateControl("btn_CfsCode") as ASPxButtonEdit;
        //ASPxComboBox cbb_Trip_BayCode = grd.FindEditFormTemplateControl("cbb_Trip_BayCode") as ASPxComboBox;
        //ASPxComboBox cbb_Carpark = grd.FindEditFormTemplateControl("cbb_Carpark") as ASPxComboBox;
        ASPxComboBox cbb_Trip_TripCode = grd.FindEditFormTemplateControl("cbb_Trip_TripCode") as ASPxComboBox;

        ASPxButtonEdit btn_DriverCode  = grd.FindEditFormTemplateControl("btn_DriverCode") as ASPxButtonEdit;
        ASPxButtonEdit btn_TowheadCode = grd.FindEditFormTemplateControl("btn_TowheadCode") as ASPxButtonEdit;
        ASPxButtonEdit btn_ChessisCode = grd.FindEditFormTemplateControl("btn_ChessisCode") as ASPxButtonEdit;
        //ASPxComboBox cbb_Trip_SubletFlag = grd.FindEditFormTemplateControl("cbb_Trip_SubletFlag") as ASPxComboBox;
        //ASPxTextBox txt_SubletHauliername = grd.FindEditFormTemplateControl("txt_SubletHauliername") as ASPxTextBox;
        //ASPxComboBox cbb_StageCode = grd.FindEditFormTemplateControl("cbb_StageCode") as ASPxComboBox;
        //ASPxComboBox cbb_StageStatus = grd.FindEditFormTemplateControl("cbb_StageStatus") as ASPxComboBox;
        ASPxComboBox cbb_Trip_StatusCode = grd.FindEditFormTemplateControl("cbb_Trip_StatusCode") as ASPxComboBox;
        ASPxComboBox cmb_DoubleMounting  = grd.FindEditFormTemplateControl("cmb_DoubleMounting") as ASPxComboBox;
        ASPxDateEdit txt_FromDate        = grd.FindEditFormTemplateControl("txt_FromDate") as ASPxDateEdit;
        ASPxTextBox  txt_Trip_fromTime   = grd.FindEditFormTemplateControl("txt_Trip_fromTime") as ASPxTextBox;
        ASPxDateEdit date_Trip_toDate    = grd.FindEditFormTemplateControl("date_Trip_toDate") as ASPxDateEdit;
        ASPxTextBox  txt_Trip_toTime     = grd.FindEditFormTemplateControl("txt_Trip_toTime") as ASPxTextBox;
        ASPxMemo     txt_Trip_Remark     = grd.FindEditFormTemplateControl("txt_Trip_Remark") as ASPxMemo;
        ASPxMemo     txt_Trip_FromCode   = grd.FindEditFormTemplateControl("txt_Trip_FromCode") as ASPxMemo;
        ASPxMemo     txt_Trip_ToCode     = grd.FindEditFormTemplateControl("txt_Trip_ToCode") as ASPxMemo;
        //ASPxSpinEdit spin_Price = grd.FindEditFormTemplateControl("spin_Price") as ASPxSpinEdit;
        ASPxComboBox cbb_zone = grd.FindEditFormTemplateControl("cbb_zone") as ASPxComboBox;
        //ASPxSpinEdit spin_Incentive1 = grd.FindEditFormTemplateControl("spin_Incentive1") as ASPxSpinEdit;
        //ASPxSpinEdit spin_Incentive2 = grd.FindEditFormTemplateControl("spin_Incentive2") as ASPxSpinEdit;
        //ASPxSpinEdit spin_Incentive3 = grd.FindEditFormTemplateControl("spin_Incentive3") as ASPxSpinEdit;
        //ASPxComboBox cbb_Incentive4 = grd.FindEditFormTemplateControl("cbb_Incentive4") as ASPxComboBox;

        //ASPxComboBox cbb_Overtime = grd.FindEditFormTemplateControl("cbb_Overtime") as ASPxComboBox;
        ASPxMemo txt_driver_remark = grd.FindEditFormTemplateControl("txt_driver_remark") as ASPxMemo;
        //ASPxComboBox cbb_OverDistance = grd.FindEditFormTemplateControl("cbb_OverDistance") as ASPxComboBox;

        ASPxTextBox fromPackingLot = grd.FindEditFormTemplateControl("txt_FromPL") as ASPxTextBox;
        ASPxTextBox toPackingLot   = grd.FindEditFormTemplateControl("txt_ToPL") as ASPxTextBox;
        //check_Trip_Status("0", trip.DriverCode,trip.Statuscode);

        //ASPxSpinEdit spin_Charge1 = grd.FindEditFormTemplateControl("spin_Charge1") as ASPxSpinEdit;
        //ASPxSpinEdit spin_Charge2 = grd.FindEditFormTemplateControl("spin_Charge2") as ASPxSpinEdit;
        //ASPxSpinEdit spin_Charge3 = grd.FindEditFormTemplateControl("spin_Charge3") as ASPxSpinEdit;
        //ASPxSpinEdit spin_Charge4 = grd.FindEditFormTemplateControl("spin_Charge4") as ASPxSpinEdit;
        //ASPxSpinEdit spin_Charge5 = grd.FindEditFormTemplateControl("spin_Charge5") as ASPxSpinEdit;
        //ASPxSpinEdit spin_Charge6 = grd.FindEditFormTemplateControl("spin_Charge6") as ASPxSpinEdit;
        //ASPxSpinEdit spin_Charge7 = grd.FindEditFormTemplateControl("spin_Charge7") as ASPxSpinEdit;
        //ASPxSpinEdit spin_Charge8 = grd.FindEditFormTemplateControl("spin_Charge8") as ASPxSpinEdit;
        //ASPxSpinEdit spin_Charge9 = grd.FindEditFormTemplateControl("spin_Charge9") as ASPxSpinEdit;
        //ASPxSpinEdit spin_Charge10 = grd.FindEditFormTemplateControl("spin_Charge10") as ASPxSpinEdit;
        ASPxSpinEdit   txt_trip_qty      = grd.FindEditFormTemplateControl("txt_trip_qty") as ASPxSpinEdit;
        ASPxButtonEdit txt_Trip_PkgsType = grd.FindEditFormTemplateControl("txt_Trip_PkgsType") as ASPxButtonEdit;
        ASPxSpinEdit   txt_trip_Wt       = grd.FindEditFormTemplateControl("txt_trip_Wt") as ASPxSpinEdit;
        ASPxSpinEdit   txt_trip_M3       = grd.FindEditFormTemplateControl("txt_trip_M3") as ASPxSpinEdit;

        if (dde_Trip_ContNo != null)
        {
            trip.ContainerNo = SafeValue.SafeString(dde_Trip_ContNo.Value);
        }
        if (dde_Trip_ContId != null)
        {
            trip.Det1Id = SafeValue.SafeInt(dde_Trip_ContId.Text, 0);
        }
        //trip.CfsCode = SafeValue.SafeString(btn_CfsCode.Value);
        //trip.BayCode = SafeValue.SafeString(cbb_Trip_BayCode.Value);
        if (btn_DriverCode != null)
        {
            trip.DriverCode = SafeValue.SafeString(btn_DriverCode.Value);
        }
        if (btn_TowheadCode != null)
        {
            trip.TowheadCode = SafeValue.SafeString(btn_TowheadCode.Value);
        }
        if (btn_ChessisCode != null)
        {
            trip.ChessisCode = SafeValue.SafeString(btn_ChessisCode.Value);
        }
        //trip.SubletFlag = SafeValue.SafeString(cbb_Trip_SubletFlag.Value);
        //trip.SubletHauliername = SafeValue.SafeString(txt_SubletHauliername.Text);
        if (cbb_Trip_TripCode != null)
        {
            trip.TripCode = SafeValue.SafeString(cbb_Trip_TripCode.Value);
        }
        if (cmb_DoubleMounting != null)
        {
            trip.DoubleMounting = SafeValue.SafeString(cmb_DoubleMounting.Value, "No");
        }
        //trip.StageCode = SafeValue.SafeString(cbb_StageCode.Value);
        //trip.Carpark = SafeValue.SafeString(cbb_Carpark.Value);
        //trip.StageStatus = SafeValue.SafeString(cbb_StageStatus.Value);
        if (cbb_Trip_StatusCode != null)
        {
            trip.Statuscode = SafeValue.SafeString(cbb_Trip_StatusCode.Value);
        }
        if (txt_FromDate != null)
        {
            trip.FromDate = SafeValue.SafeDate(txt_FromDate.Date, new DateTime(1990, 1, 1));
        }
        if (txt_Trip_fromTime != null)
        {
            trip.FromTime = SafeValue.SafeString(txt_Trip_fromTime.Text);
        }
        if (date_Trip_toDate != null)
        {
            trip.ToDate = SafeValue.SafeDate(date_Trip_toDate.Date, new DateTime(1990, 1, 1));
        }
        if (txt_Trip_toTime != null)
        {
            trip.ToTime = SafeValue.SafeString(txt_Trip_toTime.Text);
        }
        if (txt_Trip_Remark != null)
        {
            trip.Remark = SafeValue.SafeString(txt_Trip_Remark.Text);
        }
        if (txt_Trip_FromCode != null)
        {
            trip.FromCode = SafeValue.SafeString(txt_Trip_FromCode.Text);
        }
        if (txt_Trip_ToCode != null)
        {
            trip.ToCode = SafeValue.SafeString(txt_Trip_ToCode.Text);
        }
        //trip.Incentive1 = SafeValue.SafeDecimal(spin_Price.Text);
        if (cbb_zone != null)
        {
            trip.ParkingZone = SafeValue.SafeString(cbb_zone.Value);
        }
        //trip.Incentive1 = SafeValue.SafeDecimal(spin_Incentive1.Text);
        //trip.Incentive2 = SafeValue.SafeDecimal(spin_Incentive2.Text);
        //trip.Incentive3 = SafeValue.SafeDecimal(spin_Incentive3.Text);
        //trip.Incentive4 = SafeValue.SafeDecimal(cbb_Incentive4.Value);

        //trip.Overtime = SafeValue.SafeSqlString(cbb_Overtime.Value);
        //trip.OverDistance = SafeValue.SafeSqlString(cbb_OverDistance.Value);
        if (txt_driver_remark != null)
        {
            trip.Remark1 = SafeValue.SafeString(txt_driver_remark.Text);
        }
        if (fromPackingLot != null)
        {
            trip.FromParkingLot = SafeValue.SafeString(fromPackingLot.Text);
        }
        if (toPackingLot != null)
        {
            trip.ToParkingLot = SafeValue.SafeString(toPackingLot.Text);
        }

        //trip.Charge1 = SafeValue.SafeDecimal(spin_Charge1.Text);
        //trip.Charge2 = SafeValue.SafeDecimal(spin_Charge2.Text);
        //trip.Charge3 = SafeValue.SafeDecimal(spin_Charge3.Text);
        //trip.Charge4 = SafeValue.SafeDecimal(spin_Charge4.Text);
        //trip.Charge5 = SafeValue.SafeDecimal(spin_Charge5.Text);
        //trip.Charge6 = SafeValue.SafeDecimal(spin_Charge6.Text);
        //trip.Charge7 = SafeValue.SafeDecimal(spin_Charge7.Text);
        //trip.Charge8 = SafeValue.SafeDecimal(spin_Charge8.Text);
        //trip.Charge9 = SafeValue.SafeDecimal(spin_Charge9.Text);
        //trip.Charge10 = SafeValue.SafeDecimal(spin_Charge10.Text);


        if (txt_trip_qty != null)
        {
            trip.Qty = SafeValue.SafeInt(txt_trip_qty.Text, 0);
        }
        if (txt_Trip_PkgsType != null)
        {
            trip.PackageType = SafeValue.SafeString(txt_Trip_PkgsType.Text);
        }
        if (txt_trip_Wt != null)
        {
            trip.Weight = SafeValue.SafeDecimal(txt_trip_Wt.Text);
        }
        if (txt_trip_M3 != null)
        {
            trip.Volume = SafeValue.SafeDecimal(txt_trip_M3.Text);
        }


        if (isNew)
        {
            trip.JobNo = "0";
            C2.Manager.ORManager.StartTracking(trip, Wilson.ORMapper.InitialState.Inserted);
            C2.Manager.ORManager.PersistChanges(trip);
            Event_Log("", "TRIP", 1, SafeValue.SafeInt(trip.Id, 0), "");
        }
        else
        {
            C2.Manager.ORManager.StartTracking(trip, Wilson.ORMapper.InitialState.Updated);
            C2.Manager.ORManager.PersistChanges(trip);
            Event_Log("", "TRIP", 3, SafeValue.SafeInt(trip.Id, 0), "");

            //EGL_JobTrip_AfterEndTrip("", dde_Trip_ContId.Text);
        }
        string re = HttpContext.Current.User.Identity.Name + "," + trip.Id + "," + trip.DriverCode;

        if (!trip.DriverCode.Equals(Driver_old))
        {
            re += "," + Driver_old;
        }
        Session["NameTrip_" + trip.Id] = "Id=" + trip.Id + "";
        this.dsTrip.FilterExpression   = Session["NameTrip_" + trip.Id].ToString();
        if (this.grid_Trip.GetRow(0) != null)
        {
            this.grid_Trip.CancelEdit();
        }
        e.Result = re;
    }
コード例 #20
0
    protected void grid_Cost_RowInserting(object sender, DevExpress.Web.Data.ASPxDataInsertingEventArgs e)
    {
        ASPxPageControl pageControl = this.grid_Transport.FindEditFormTemplateControl("pageControl") as ASPxPageControl;
        ASPxTextBox     refNo       = pageControl.FindControl("txt_JobNo") as ASPxTextBox;

        e.NewValues["JobType"]    = "Tpt";
        e.NewValues["RefNo"]      = refNo.Text;
        e.NewValues["SaleDocAmt"] = SafeValue.ChinaRound(SafeValue.SafeDecimal(e.NewValues["SaleQty"], 0) * SafeValue.SafeDecimal(e.NewValues["SalePrice"], 0), 2);
        e.NewValues["SaleLocAmt"] = SafeValue.ChinaRound(SafeValue.SafeDecimal(e.NewValues["SaleDocAmt"], 0) * SafeValue.SafeDecimal(e.NewValues["SaleExRate"], 0), 2);

        e.NewValues["CostDocAmt"] = SafeValue.ChinaRound(SafeValue.SafeDecimal(e.NewValues["CostQty"], 0) * SafeValue.SafeDecimal(e.NewValues["CostPrice"], 0), 2);
        e.NewValues["CostLocAmt"] = SafeValue.ChinaRound(SafeValue.SafeDecimal(e.NewValues["CostDocAmt"], 0) * SafeValue.SafeDecimal(e.NewValues["CostExRate"], 0), 2);
    }
コード例 #21
0
    private void OnLoad()
    {
        int start = 0;    // this.ASPxGridView1.PageIndex * ASPxGridView1.SettingsPager.PageSize;
        int end   = 1000; // (ASPxGridView1.PageIndex + 1) * ASPxGridView1.SettingsPager.PageSize;

        for (int i = start; i < end; i++)
        {
            ASPxCheckBox isPay            = this.grid.FindRowCellTemplateControl(i, (DevExpress.Web.ASPxGridView.GridViewDataColumn) this.grid.Columns["Id"], "ack_IsPay") as ASPxCheckBox;
            ASPxLabel    Id               = this.grid.FindRowCellTemplateControl(i, (DevExpress.Web.ASPxGridView.GridViewDataColumn) this.grid.Columns["Id"], "lbl_Id") as ASPxLabel;
            ASPxDateEdit date_ShipDate    = this.grid.FindRowCellTemplateControl(i, (DevExpress.Web.ASPxGridView.GridViewDataColumn) this.grid.Columns["ShipDate"], "date_ShipDate") as ASPxDateEdit;
            ASPxTextBox  txt_ShipIndex    = this.grid.FindRowCellTemplateControl(i, (DevExpress.Web.ASPxGridView.GridViewDataColumn) this.grid.Columns["ShipIndex"], "txt_ShipIndex") as ASPxTextBox;
            ASPxTextBox  txt_ShipPortCode = this.grid.FindRowCellTemplateControl(i, (DevExpress.Web.ASPxGridView.GridViewDataColumn) this.grid.Columns["ShipPortCode"], "txt_ShipPortCode") as ASPxTextBox;
            ASPxComboBox cbb_ContIndex    = this.grid.FindRowCellTemplateControl(i, (DevExpress.Web.ASPxGridView.GridViewDataColumn) this.grid.Columns["ContIndex"], "cbb_ContIndex") as ASPxComboBox;
            ASPxSpinEdit spin_Qty         = this.grid.FindRowCellTemplateControl(i, (DevExpress.Web.ASPxGridView.GridViewDataColumn) this.grid.Columns["QtyOrig"], "spin_Qty") as ASPxSpinEdit;
            ASPxSpinEdit spin_Weight      = this.grid.FindRowCellTemplateControl(i, (DevExpress.Web.ASPxGridView.GridViewDataColumn) this.grid.Columns["WeightOrig"], "spin_Weight") as ASPxSpinEdit;
            ASPxSpinEdit spin_Volume      = this.grid.FindRowCellTemplateControl(i, (DevExpress.Web.ASPxGridView.GridViewDataColumn) this.grid.Columns["VolumeOrig"], "spin_Volume") as ASPxSpinEdit;

            if (Id != null && isPay != null && isPay.Checked)
            {
                list.Add(new Record(SafeValue.SafeInt(Id.Text, 0), SafeValue.SafeInt(txt_ShipIndex.Value, 0), date_ShipDate.Date, txt_ShipPortCode.Text, SafeValue.SafeString(cbb_ContIndex.Value), SafeValue.SafeDecimal(spin_Qty.Value), SafeValue.SafeDecimal(spin_Weight.Value), SafeValue.SafeDecimal(spin_Volume.Value)));
            }
            else
            {
                if (Id == null)
                {
                    break;
                }
            }
        }
    }
コード例 #22
0
    protected void grid_Cost_RowUpdating(object sender, DevExpress.Web.Data.ASPxDataUpdatingEventArgs e)
    {
        e.NewValues["SaleDocAmt"] = SafeValue.ChinaRound(SafeValue.SafeDecimal(e.NewValues["SaleQty"], 0) * SafeValue.SafeDecimal(e.NewValues["SalePrice"], 0), 2);
        e.NewValues["SaleLocAmt"] = SafeValue.ChinaRound(SafeValue.SafeDecimal(e.NewValues["SaleDocAmt"], 0) * SafeValue.SafeDecimal(e.NewValues["SaleExRate"], 0), 2);

        e.NewValues["CostDocAmt"] = SafeValue.ChinaRound(SafeValue.SafeDecimal(e.NewValues["CostQty"], 0) * SafeValue.SafeDecimal(e.NewValues["CostPrice"], 0), 2);
        e.NewValues["CostLocAmt"] = SafeValue.ChinaRound(SafeValue.SafeDecimal(e.NewValues["CostDocAmt"], 0) * SafeValue.SafeDecimal(e.NewValues["CostExRate"], 0), 2);
    }
コード例 #23
0
    private void OnLoad()
    {
        int start = 0;
        int end   = count;

        for (int i = start; i < end; i++)
        {
            ASPxCheckBox isPay = this.grid.FindRowCellTemplateControl(i, (DevExpress.Web.ASPxGridView.GridViewDataColumn) this.grid.Columns["Id"], "ack_IsPay") as ASPxCheckBox;

            ASPxTextBox  id             = this.grid.FindRowCellTemplateControl(i, (DevExpress.Web.ASPxGridView.GridViewDataColumn) this.grid.Columns["Id"], "txt_Id") as ASPxTextBox;
            ASPxTextBox  txt_ContNo     = this.grid.FindRowCellTemplateControl(i, (DevExpress.Web.ASPxGridView.GridViewDataColumn) this.grid.Columns["ContNo"], "txt_ContNo") as ASPxTextBox;
            ASPxComboBox cbbContType    = this.grid.FindRowCellTemplateControl(i, (DevExpress.Web.ASPxGridView.GridViewDataColumn) this.grid.Columns["ContType"], "cbbContType") as ASPxComboBox;
            ASPxSpinEdit spin_Price     = this.grid.FindRowCellTemplateControl(i, (DevExpress.Web.ASPxGridView.GridViewDataColumn) this.grid.Columns["Price"], "spin_Price") as ASPxSpinEdit;
            ASPxTextBox  txt_Unit       = this.grid.FindRowCellTemplateControl(i, (DevExpress.Web.ASPxGridView.GridViewDataColumn) this.grid.Columns["Unit"], "txt_Unit") as ASPxTextBox;
            ASPxSpinEdit spin_Qty       = this.grid.FindRowCellTemplateControl(i, (DevExpress.Web.ASPxGridView.GridViewDataColumn) this.grid.Columns["Qty"], "spin_Qty") as ASPxSpinEdit;
            ASPxSpinEdit spin_LineIndex = this.grid.FindRowCellTemplateControl(i, (DevExpress.Web.ASPxGridView.GridViewDataColumn) this.grid.Columns["LineIndex"], "spin_LineIndex") as ASPxSpinEdit;
            ASPxComboBox cbb_ChgCode    = this.grid.FindRowCellTemplateControl(i, (DevExpress.Web.ASPxGridView.GridViewDataColumn) this.grid.Columns["ChgCode"], "cbb_ChgCode") as ASPxComboBox;
            ASPxTextBox  txt_ChgCodeDe  = this.grid.FindRowCellTemplateControl(i, (DevExpress.Web.ASPxGridView.GridViewDataColumn) this.grid.Columns["ChgCodeDe"], "txt_ChgCodeDe") as ASPxTextBox;
            ASPxTextBox  txt_Remark     = this.grid.FindRowCellTemplateControl(i, (DevExpress.Web.ASPxGridView.GridViewDataColumn) this.grid.Columns["Remark"], "txt_Remark") as ASPxTextBox;
            ASPxTextBox  txt_GroupBy    = this.grid.FindRowCellTemplateControl(i, (DevExpress.Web.ASPxGridView.GridViewDataColumn) this.grid.Columns["GroupBy"], "txt_GroupBy") as ASPxTextBox;
            if (id != null && isPay != null && isPay.Checked)
            {
                list.Add(new Record(SafeValue.SafeInt(id.Text, 0), txt_ContNo.Text, SafeValue.SafeString(cbbContType.Value), SafeValue.SafeDecimal(spin_Price.Value), SafeValue.SafeDecimal(spin_Qty.Value),
                                    SafeValue.SafeString(cbb_ChgCode.Value), txt_ChgCodeDe.Text, txt_Unit.Text, SafeValue.SafeInt(spin_LineIndex.Value, 0), txt_Remark.Text, txt_GroupBy.Text));
            }
            else if (id == null)
            {
                break;
            }
        }
    }
コード例 #24
0
    protected string SaveJob()
    {
        try
        {
            ASPxPageControl pageControl = this.grid_Transport.FindEditFormTemplateControl("pageControl") as ASPxPageControl;
            ASPxTextBox     idCtr       = pageControl.FindControl("txt_Id") as ASPxTextBox;
            ASPxTextBox     jobNoCtr    = pageControl.FindControl("txt_JobNo") as ASPxTextBox;

            string jobNo = jobNoCtr.Text;
            Wilson.ORMapper.OPathQuery query = new Wilson.ORMapper.OPathQuery(typeof(C2.TptJob), "Id='" + idCtr.Text + "'");
            C2.TptJob tj    = C2.Manager.ORManager.GetObject(query) as C2.TptJob;
            bool      isNew = false;

            bool         isAddTripLog = false;
            string       runType      = "LocalTpt";
            ASPxDateEdit jobDate      = pageControl.FindControl("date_JobDate") as ASPxDateEdit;
            if (tj == null)
            {
                tj         = new C2.TptJob();
                isNew      = true;
                tj.JobType = this.txt_type.Text;
                jobNo      = C2Setup.GetNextNo(tj.JobType, runType, jobDate.Date);
                tj.JobNo   = jobNo;
            }
            tj.JobDate = jobDate.Date;
            ASPxComboBox jobType = pageControl.FindControl("cmb_JobType") as ASPxComboBox;
            tj.JobType = jobType.Text;
            ASPxButtonEdit cust = pageControl.FindControl("btn_Cust") as ASPxButtonEdit;
            tj.Cust = cust.Text;
            ASPxTextBox bkgRef = pageControl.FindControl("txt_BkgRef") as ASPxTextBox;
            tj.BkgRef = bkgRef.Text;
            ASPxTextBox pic = pageControl.FindControl("txt_CustPic") as ASPxTextBox;
            tj.CustPic = pic.Text;
            ASPxTextBox email = pageControl.FindControl("txt_CustEmail") as ASPxTextBox;
            tj.CustEmail = email.Text;
            ASPxTextBox docNo = pageControl.FindControl("txt_CustDocNo") as ASPxTextBox;
            tj.CustDocNo = docNo.Text;
            ASPxComboBox custDocType = pageControl.FindControl("txt_CustDocType") as ASPxComboBox;
            tj.CustDocType = custDocType.Text;

            ASPxTextBox ves = pageControl.FindControl("txt_Ves") as ASPxTextBox;
            tj.Vessel = ves.Text;
            ASPxTextBox voy = pageControl.FindControl("txt_Voy") as ASPxTextBox;
            tj.Voyage = voy.Text;
            ASPxButtonEdit pol = pageControl.FindControl("txt_Pol") as ASPxButtonEdit;
            tj.Pol = pol.Text;
            ASPxButtonEdit pod = pageControl.FindControl("txt_Pod") as ASPxButtonEdit;
            tj.Pod = pod.Text;
            ASPxDateEdit eta = pageControl.FindControl("date_Eta") as ASPxDateEdit;
            tj.Eta = eta.Date;
            ASPxDateEdit etd = pageControl.FindControl("date_Etd") as ASPxDateEdit;
            tj.Etd = etd.Date;
            ASPxTextBox blRef = pageControl.FindControl("txt_BlRef") as ASPxTextBox;
            tj.BlRef = blRef.Text;



            ASPxDateEdit bkgDate = pageControl.FindControl("date_BkgDate") as ASPxDateEdit;
            tj.BkgDate = SafeValue.SafeDate(bkgDate.Date, new DateTime(1753, 1, 1));
            ASPxTextBox bkgTime = pageControl.FindControl("txt_BkgTime") as ASPxTextBox;
            tj.BkgTime = bkgTime.Text;
            ASPxTextBox jobRmk = pageControl.FindControl("txt_JobRmk") as ASPxTextBox;
            tj.JobRmk = jobRmk.Text;

            ASPxSpinEdit bkgqty = pageControl.FindControl("spin_BkgQty") as ASPxSpinEdit;
            tj.BkgQty = SafeValue.SafeInt(bkgqty.Value, 0);
            ASPxButtonEdit bkgpkgType = pageControl.FindControl("txt_BkgPackType") as ASPxButtonEdit;
            tj.BkgPkgType = bkgpkgType.Text;
            ASPxSpinEdit bkgwt = pageControl.FindControl("spin_BkgWt") as ASPxSpinEdit;
            tj.BkgWt = SafeValue.SafeDecimal(bkgwt.Value, 0);
            ASPxSpinEdit bkgm3 = pageControl.FindControl("spin_BkgM3") as ASPxSpinEdit;
            tj.BkgM3 = SafeValue.SafeDecimal(bkgm3.Value, 0);

            ASPxMemo pickFrm1 = pageControl.FindControl("txt_PickupFrm1") as ASPxMemo;
            tj.PickFrm1 = pickFrm1.Text;
            ASPxMemo deliveryTo1 = pageControl.FindControl("txt_DeliveryTo1") as ASPxMemo;
            tj.DeliveryTo1 = deliveryTo1.Text;
            ASPxMemo mkg = pageControl.FindControl("txt_cargoMkg") as ASPxMemo;
            tj.CargoMkg = mkg.Text;
            ASPxMemo des = pageControl.FindControl("txt_cargoDes") as ASPxMemo;
            tj.CargoDesc = des.Text;


            ASPxDateEdit tptDate = pageControl.FindControl("date_TptDate") as ASPxDateEdit;
            tj.TptDate = SafeValue.SafeDate(tptDate.Date, new DateTime(1753, 1, 1));
            ASPxTextBox tptTime = pageControl.FindControl("txt_TptTime") as ASPxTextBox;
            tj.TptTime = tptTime.Text;
            ASPxComboBox JobProgress = pageControl.FindControl("cmb_JobStatus") as ASPxComboBox;
            if (!isNew && tj.JobProgress != JobProgress.Text)
            {
                isAddTripLog = true;
            }
            tj.JobProgress = JobProgress.Text;
            ASPxComboBox tptType = pageControl.FindControl("cmb_TptType") as ASPxComboBox;
            tj.TptType = tptType.Text;
            ASPxComboBox tipCode = pageControl.FindControl("cbb_Trip_TripCode") as ASPxComboBox;
            tj.TripCode = tipCode.Text;

            ASPxButtonEdit driver = pageControl.FindControl("btn_DriverCode") as ASPxButtonEdit;
            tj.Driver = driver.Text;
            ASPxButtonEdit vehicle = pageControl.FindControl("btn_vehicle") as ASPxButtonEdit;
            tj.VehicleNo = vehicle.Text;

            ASPxSpinEdit qty = pageControl.FindControl("spin_Qty") as ASPxSpinEdit;
            tj.Qty = SafeValue.SafeInt(qty.Value, 0);
            ASPxButtonEdit pkgType = pageControl.FindControl("txt_PackType") as ASPxButtonEdit;
            tj.PkgType = pkgType.Text;
            ASPxSpinEdit wt = pageControl.FindControl("spin_Wt") as ASPxSpinEdit;
            tj.Wt = SafeValue.SafeDecimal(wt.Value, 0);
            ASPxSpinEdit m3 = pageControl.FindControl("spin_M3") as ASPxSpinEdit;
            tj.M3 = SafeValue.SafeDecimal(m3.Value, 0);


            ASPxSpinEdit FeeTpt = pageControl.FindControl("spin_FeeTpt") as ASPxSpinEdit;
            tj.FeeTpt = SafeValue.SafeDecimal(FeeTpt.Value, 0);
            ASPxSpinEdit FeeLabour = pageControl.FindControl("spin_FeeLabour") as ASPxSpinEdit;
            tj.FeeLabour = SafeValue.SafeDecimal(FeeLabour.Value, 0);
            ASPxSpinEdit FeeOt = pageControl.FindControl("spin_FeeOt") as ASPxSpinEdit;
            tj.FeeOt = SafeValue.SafeDecimal(FeeOt.Value, 0);
            ASPxSpinEdit FeeAdmin = pageControl.FindControl("spin_FeeAdmin") as ASPxSpinEdit;
            tj.FeeAdmin = SafeValue.SafeDecimal(FeeAdmin.Value, 0);
            ASPxSpinEdit FeeReimberse = pageControl.FindControl("spin_FeeReimberse") as ASPxSpinEdit;
            tj.FeeReimberse = SafeValue.SafeDecimal(FeeReimberse.Value, 0);
            ASPxSpinEdit FeeMisc = pageControl.FindControl("spin_FeeMisc") as ASPxSpinEdit;
            tj.FeeMisc = SafeValue.SafeDecimal(FeeMisc.Value, 0);

            tj.FeeTotal = tj.FeeTpt + tj.FeeLabour + tj.FeeOt + tj.FeeAdmin + tj.FeeReimberse + tj.FeeMisc;
            ASPxTextBox FeeRemark = pageControl.FindControl("txt_FeeRemark") as ASPxTextBox;
            tj.FeeRemark = FeeRemark.Text;


            if (isNew)
            {
                tj.CreateBy       = EzshipHelper.GetUserName();
                tj.CreateDateTime = DateTime.Now;
                tj.StatusCode     = "USE";
                C2.Manager.ORManager.StartTracking(tj, Wilson.ORMapper.InitialState.Inserted);
                C2.Manager.ORManager.PersistChanges(tj);
                if (tj.JobProgress == "Assigned")
                {
                    InsertTripLog(tj);
                }
            }
            else
            {
                tj.UpdateBy       = EzshipHelper.GetUserName();
                tj.UpdateDateTime = DateTime.Now;

                C2.Manager.ORManager.StartTracking(tj, Wilson.ORMapper.InitialState.Updated);
                C2.Manager.ORManager.PersistChanges(tj);
                if (isAddTripLog)
                {
                    InsertTripLog(tj);
                }
            }
            if (isNew)
            {
                jobNoCtr.Text = jobNo;
                C2Setup.SetNextNo(tj.JobType, runType, jobNo, tj.JobDate);
                string where = "JobNo='" + jobNo + "'";
                Session["TptJob_" + this.txt_type.Text] = where;
                this.dsTransport.FilterExpression       = where;
                if (this.grid_Transport.GetRow(0) != null)
                {
                    this.grid_Transport.StartEdit(0);
                }
            }
            string re = HttpContext.Current.User.Identity.Name + "," + tj.Driver + "," + tj.JobNo;
            return(re);
        }
        catch (Exception ex)
        { throw new Exception(ex.Message); }
    }
コード例 #25
0
    private void OnLoad(string r)
    {
        int start = 0;     // this.ASPxGridView1.PageIndex * ASPxGridView1.SettingsPager.PageSize;
        int end   = 10000; // (ASPxGridView1.PageIndex + 1) * ASPxGridView1.SettingsPager.PageSize;

        for (int i = start; i < end; i++)
        {
            ASPxTextBox  docId      = this.ASPxGridView1.FindRowTemplateControl(i, "txt_docId") as ASPxTextBox;
            ASPxSpinEdit payAmt     = this.ASPxGridView1.FindRowTemplateControl(i, "spin_Amt") as ASPxSpinEdit;
            ASPxSpinEdit balanceAmt = this.ASPxGridView1.FindRowTemplateControl(i, "spin_BalanceAmt") as ASPxSpinEdit;
            ASPxCheckBox isPay      = this.ASPxGridView1.FindRowTemplateControl(i, "ack_IsPay") as ASPxCheckBox;
            if (docId != null && payAmt != null && isPay != null && isPay.Checked)
            {
                if (SafeValue.SafeDecimal(payAmt.Value, 0) > 0 && SafeValue.SafeDecimal(payAmt.Value, 0) <= SafeValue.SafeDecimal(balanceAmt.Value, 0))
                {
                    totPayAmt += SafeValue.SafeDecimal(payAmt.Value, 0);
                    list.Add(new Record(docId.Text,
                                        SafeValue.SafeDecimal(payAmt.Value, 0)
                                        ));
                }
            }
        }
    }
コード例 #26
0
    protected void ASPxGridView1_CustomCallback(object sender, DevExpress.Web.ASPxGridView.ASPxGridViewCustomCallbackEventArgs e)
    {
        ASPxTextBox  oidCtr   = this.ASPxGridView1.FindEditFormTemplateControl("txt_Oid") as ASPxTextBox;
        ASPxComboBox partyTo  = this.ASPxGridView1.FindEditFormTemplateControl("cmb_PartyTo") as ASPxComboBox;
        ASPxTextBox  docN     = this.ASPxGridView1.FindEditFormTemplateControl("txt_DocNo") as ASPxTextBox;
        ASPxComboBox docType  = this.ASPxGridView1.FindEditFormTemplateControl("cbo_DocType") as ASPxComboBox;
        ASPxMemo     remark   = this.ASPxGridView1.FindEditFormTemplateControl("txt_Remarks1") as ASPxMemo;
        ASPxComboBox termId   = this.ASPxGridView1.FindEditFormTemplateControl("txt_TermId") as ASPxComboBox;
        ASPxTextBox  docCurr  = this.ASPxGridView1.FindEditFormTemplateControl("txt_Currency") as ASPxTextBox;
        ASPxSpinEdit exRate   = this.ASPxGridView1.FindEditFormTemplateControl("txt_DocExRate") as ASPxSpinEdit;
        ASPxTextBox  acCode   = this.ASPxGridView1.FindEditFormTemplateControl("txt_AcCode") as ASPxTextBox;
        ASPxTextBox  acSource = this.ASPxGridView1.FindEditFormTemplateControl("txt_AcSource") as ASPxTextBox;

        ASPxTextBox  supplierBillNo   = this.ASPxGridView1.FindEditFormTemplateControl("txt_SupplierBillNo") as ASPxTextBox;
        ASPxDateEdit supplierBillDate = this.ASPxGridView1.FindEditFormTemplateControl("txt_SupplierBillDate") as ASPxDateEdit;
        ASPxDateEdit eta  = this.ASPxGridView1.FindEditFormTemplateControl("txt_Eta") as ASPxDateEdit;
        string       invN = docN.Text;

        C2.XAApPayable inv   = Manager.ORManager.GetObject(typeof(XAApPayable), SafeValue.SafeInt(oidCtr.Text, 0)) as XAApPayable;
        bool           isNew = false;

        if (invN.Length < 1)        // first insert invoice
        {
            if (supplierBillNo.Text.Trim().Length > 0)
            {
                string sqlCnt = string.Format("select DocNo from XaApPayable where SupplierBillNo='{0}' and PartyTo='{1}' and DocType='{2}' AND CancelInd='N'", supplierBillNo.Text.Trim(), SafeValue.SafeString(partyTo.Value, ""), docType.Value.ToString());
                string billNo = SafeValue.SafeString(C2.Manager.ORManager.ExecuteScalar(sqlCnt), "");
                if (billNo.Length > 0)
                {
                    throw new Exception(string.Format("Have this Supplier Bill No In {0}({1})", billNo, docType.Value.ToString()));
                    return;
                }
            }

            isNew = true;
            inv   = new XAApPayable();
            //invN = C2Setup.GetNextNo("AP-PAYABLE");
            string counterType = "AP-PAYABLE";
            invN = C2Setup.GetNextNo(inv.DocType, counterType, supplierBillDate.Date);

            inv.PartyTo     = SafeValue.SafeString(partyTo.Value, "");
            inv.MastType    = "";         //SafeValue.SafeString(docCate.Value, "");
            inv.DocType     = docType.Value.ToString();
            inv.DocNo       = invN.ToString();
            inv.Term        = termId.Text;
            inv.Description = remark.Text;
            inv.CurrencyId  = docCurr.Text.ToString();
            inv.ExRate      = SafeValue.SafeDecimal(exRate.Value, 1);
            if (inv.ExRate <= 0)
            {
                inv.ExRate = 1;
            }
            inv.AcCode   = EzshipHelper.GetAccApCode(inv.PartyTo, inv.CurrencyId);
            inv.AcSource = acSource.Text;

            inv.ExportInd  = "N";
            inv.UserId     = HttpContext.Current.User.Identity.Name;
            inv.EntryDate  = DateTime.Now;
            inv.CancelDate = new DateTime(1900, 1, 1);
            inv.CancelInd  = "N";

            inv.SupplierBillNo   = supplierBillNo.Text;
            inv.SupplierBillDate = SafeValue.SafeDate(supplierBillDate.Date, DateTime.Today);
            inv.DocDate          = inv.SupplierBillDate;
            inv.ChqNo            = "";
            inv.ChqDate          = new DateTime(1900, 1, 1);

            inv.MastRefNo = "0";
            inv.JobRefNo  = "0";
            inv.MastType  = "";
            inv.Eta       = eta.Date;
            string[] currentPeriod = EzshipHelper.GetAccPeriod(inv.DocDate);

            inv.AcYear   = SafeValue.SafeInt(currentPeriod[1], inv.DocDate.Year);
            inv.AcPeriod = SafeValue.SafeInt(currentPeriod[0], inv.DocDate.Month);
            try
            {
                C2.Manager.ORManager.StartTracking(inv, Wilson.ORMapper.InitialState.Inserted);
                C2.Manager.ORManager.PersistChanges(inv);
                //C2Setup.SetNextNo("AP-PAYABLE", invN);
                C2Setup.SetNextNo("", counterType, invN, inv.DocDate);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message + ex.StackTrace);
            }
        }
        else
        {
            if (supplierBillNo.Text.Trim().Length > 0)
            {
                string sqlCnt = string.Format("select DocNo from XaApPayable where SupplierBillNo='{0}' and PartyTo='{1}' and DocType='{2}' and DocNo!='{3}' AND CancelInd='N'", supplierBillNo.Text.Trim(), SafeValue.SafeString(partyTo.Value, ""), docType.Value.ToString(), inv.DocNo);
                string billNo = SafeValue.SafeString(C2.Manager.ORManager.ExecuteScalar(sqlCnt), "");
                if (billNo.Length > 0)
                {
                    throw new Exception(string.Format("Have this Supplier Bill No In {0}({1})", billNo, docType.Value.ToString()));
                    return;
                }
            }

            inv.PartyTo     = SafeValue.SafeString(partyTo.Value, "");
            inv.Term        = termId.Text;
            inv.Description = remark.Text;
            inv.CurrencyId  = docCurr.Text.ToString();
            inv.ExRate      = SafeValue.SafeDecimal(exRate.Value, 1);
            if (inv.ExRate <= 0)
            {
                inv.ExRate = 1;
            }
            inv.AcCode   = EzshipHelper.GetAccApCode(inv.PartyTo, inv.CurrencyId);
            inv.AcSource = acSource.Text;

            inv.SupplierBillNo   = supplierBillNo.Text;
            inv.SupplierBillDate = SafeValue.SafeDate(supplierBillDate.Date, DateTime.Now);
            inv.DocDate          = inv.SupplierBillDate;
            inv.Eta = eta.Date;
            string[] currentPeriod = EzshipHelper.GetAccPeriod(inv.DocDate);

            inv.AcYear   = SafeValue.SafeInt(currentPeriod[1], inv.DocDate.Year);
            inv.AcPeriod = SafeValue.SafeInt(currentPeriod[0], inv.DocDate.Month);
            try
            {
                Manager.ORManager.StartTracking(inv, InitialState.Updated);
                Manager.ORManager.PersistChanges(inv);
                UpdateMaster(inv.SequenceId.ToString());
            }
            catch
            {
            }
        }

        Session["PvEditWhere"]            = "SequenceId=" + inv.SequenceId;
        this.dsApPayable.FilterExpression = Session["PvEditWhere"].ToString();
        if (isNew)
        {
            if (this.ASPxGridView1.GetRow(0) != null)
            {
                this.ASPxGridView1.StartEdit(0);
            }
        }
    }
コード例 #27
0
    protected void grid_InvDet_RowInserting(object sender, DevExpress.Web.Data.ASPxDataInsertingEventArgs e)
    {
        ASPxGridView grd        = sender as ASPxGridView;
        string       sql_detCnt = "select max(QuoteLineNo) from SeaApQuoteDet1 where QuoteId='" + SafeValue.SafeInt(grd.GetMasterRowKeyValue(), 0) + "'";
        int          lineNo     = SafeValue.SafeInt(Manager.ORManager.ExecuteScalar(sql_detCnt), 0) + 1;

        e.NewValues["QuoteId"]     = SafeValue.SafeString(grd.GetMasterRowKeyValue(), "");
        e.NewValues["QuoteLineNo"] = lineNo;
        e.NewValues["Qty"]         = (decimal)1;
        if (SafeValue.SafeString(e.NewValues["GstType"], "") == "S")
        {
            e.NewValues["Gst"] = (decimal)0.07;
        }
        else
        {
            e.NewValues["Gst"] = (decimal)0;
        }
        e.NewValues["Amt"] = SafeValue.SafeDecimal(e.NewValues["Price"], 0) * SafeValue.SafeDecimal(e.NewValues["Qty"], 1) * (1 + SafeValue.SafeDecimal(e.NewValues["Gst"], 0));
    }
コード例 #28
0
    protected void grid_InvDet_RowInserting(object sender, DevExpress.Web.Data.ASPxDataInsertingEventArgs e)
    {
        ASPxTextBox oidCtr = this.ASPxGridView1.FindEditFormTemplateControl("txt_Oid") as ASPxTextBox;

        string sql_detCnt = "select count(*) from XAApPayableDet where DocId='" + oidCtr.Text + "'";
        int    lineNo     = SafeValue.SafeInt(Manager.ORManager.ExecuteScalar(sql_detCnt), 0) + 1;

        //e.NewValues["CostingId"] = "";
        e.NewValues["DocId"]     = SafeValue.SafeInt(oidCtr.Text, 0);
        e.NewValues["DocLineNo"] = lineNo;
        ASPxTextBox  billN   = this.ASPxGridView1.FindEditFormTemplateControl("txt_SupplierBillNo") as ASPxTextBox;
        string       billNo  = S.Text(billN.Text).Trim();
        ASPxTextBox  docN    = this.ASPxGridView1.FindEditFormTemplateControl("txt_DocNo") as ASPxTextBox;
        ASPxComboBox docType = this.ASPxGridView1.FindEditFormTemplateControl("cbo_DocType") as ASPxComboBox;

        e.NewValues["DocNo"]   = docN.Text;
        e.NewValues["DocType"] = docType.Text;
        if (!e.NewValues["Currency"].Equals("SGD"))
        {
            e.NewValues["GstType"] = "Z";
            e.NewValues["Gst"]     = new decimal(0);
        }
        if (SafeValue.SafeDecimal(e.NewValues["ExRate"], 1) == 0)
        {
            e.NewValues["ExRate"] = 1;
        }
        decimal amt    = SafeValue.ChinaRound(SafeValue.SafeDecimal(e.NewValues["Qty"], 0) * SafeValue.SafeDecimal(e.NewValues["Price"], 0), 2);
        decimal gstAmt = SafeValue.ChinaRound((amt * SafeValue.SafeDecimal(e.NewValues["Gst"], 0)), 2);
        decimal docAmt = amt + gstAmt;
        decimal locAmt = SafeValue.ChinaRound(docAmt * SafeValue.SafeDecimal(e.NewValues["ExRate"], 1), 2);

        e.NewValues["GstAmt"] = gstAmt;
        e.NewValues["DocAmt"] = docAmt;
        e.NewValues["LocAmt"] = locAmt;
        string _jobno  = S.Text(e.NewValues["MastRefNo"]).Trim();
        string _contno = S.Text(e.NewValues["JobRefNo"]).Trim();

        e.NewValues["MastRefNo"] = _jobno;
        e.NewValues["JobRefNo"]  = _contno;

        if (_jobno.Length > 5 && _contno.Length > 5)
        {
            string sqlPsa = string.Format("update psa_bill set Job_No='{0}' where [Bill Number]='{1}' and [Bill Item Number]='{2}' and [Container Number]='{3}'",
                                          _jobno, billNo, e.NewValues["DocLineNo"],
                                          _contno
                                          );
            D.Exec(sqlPsa);
        }

        //e.NewValues["MastType"] = "";
        //e.NewValues["MastRefNo"] = "0";
        //e.NewValues["JobRefNo"] = "0";
    }
コード例 #29
0
    protected void ASPxGridView1_CustomCallback(object sender, DevExpress.Web.ASPxGridView.ASPxGridViewCustomCallbackEventArgs e)
    {
        ASPxTextBox invNCtr = this.ASPxGridView1.FindEditFormTemplateControl("txt_Oid") as ASPxTextBox;

        ASPxTextBox    title   = this.ASPxGridView1.FindEditFormTemplateControl("txt_Title") as ASPxTextBox;
        ASPxButtonEdit partyTo = this.ASPxGridView1.FindEditFormTemplateControl("txt_CustId") as ASPxButtonEdit;
        ASPxTextBox    docN    = this.ASPxGridView1.FindEditFormTemplateControl("txt_DocNo") as ASPxTextBox;
        ASPxDateEdit   docDate = this.ASPxGridView1.FindEditFormTemplateControl("txt_DocDt") as ASPxDateEdit;
        ASPxMemo       note    = this.ASPxGridView1.FindEditFormTemplateControl("txt_Note") as ASPxMemo;
        ASPxMemo       rmk     = this.ASPxGridView1.FindEditFormTemplateControl("txt_Remarks1") as ASPxMemo;
        // ASPxComboBox termId = this.ASPxGridView1.FindEditFormTemplateControl("txt_TermId") as ASPxComboBox;
        ASPxDateEdit   expireDt = this.ASPxGridView1.FindEditFormTemplateControl("txt_toDt") as ASPxDateEdit;
        ASPxButtonEdit docCurr  = this.ASPxGridView1.FindEditFormTemplateControl("txt_Currency") as ASPxButtonEdit;
        ASPxButtonEdit pol      = this.ASPxGridView1.FindEditFormTemplateControl("txt_Pol") as ASPxButtonEdit;
        ASPxButtonEdit pod      = this.ASPxGridView1.FindEditFormTemplateControl("txt_Pod") as ASPxButtonEdit;
        ASPxButtonEdit viaPort  = this.ASPxGridView1.FindEditFormTemplateControl("txt_ViaPort") as ASPxButtonEdit;


        ASPxTextBox frequency = this.ASPxGridView1.FindEditFormTemplateControl("txt_Frequency") as ASPxTextBox;
        ASPxTextBox attention = this.ASPxGridView1.FindEditFormTemplateControl("txt_Attention") as ASPxTextBox;
        ASPxTextBox tsDay     = this.ASPxGridView1.FindEditFormTemplateControl("spin_TsDay") as ASPxTextBox;
        //ASPxSpinEdit gp20 = this.ASPxGridView1.FindEditFormTemplateControl("spin_Gp20") as ASPxSpinEdit;
        // ASPxSpinEdit gp40 = this.ASPxGridView1.FindEditFormTemplateControl("spin_Gp40") as ASPxSpinEdit;
        //ASPxSpinEdit hc40 = this.ASPxGridView1.FindEditFormTemplateControl("spin_Hc40") as ASPxSpinEdit;
        ASPxComboBox contType  = this.ASPxGridView1.FindEditFormTemplateControl("cbx_ContType") as ASPxComboBox;
        ASPxSpinEdit contPrice = this.ASPxGridView1.FindEditFormTemplateControl("spin_contPrice") as ASPxSpinEdit;
        ASPxSpinEdit exRate    = this.ASPxGridView1.FindEditFormTemplateControl("spin_exRate") as ASPxSpinEdit;

        string invN = docN.Text;

        C2.SeaApQuote1 inv = Manager.ORManager.GetObject(typeof(SeaApQuote1), SafeValue.SafeInt(invNCtr.Text, 0)) as SeaApQuote1;
        if (inv == null)// first insert invoice
        {
            string counterType = "SeaFcl-ApQuotation";

            inv           = new SeaApQuote1();
            invN          = C2Setup.GetNextNo(counterType);
            inv.Title     = title.Text;
            inv.PartyTo   = SafeValue.SafeString(partyTo.Value, "");
            inv.QuoteNo   = invN.ToString();
            inv.QuoteDate = docDate.Date;
            inv.ImpExpInd = "E";
            inv.FclLclInd = "Fcl";
            // inv.Term = termId.Text;

            //inv.DocFromDate =SafeValue.SafeDate(fromDt.Text, DateTime.Now);
            inv.ExpireDate = SafeValue.SafeDate(expireDt.Text, DateTime.Now);
            inv.Rmk        = rmk.Text;
            inv.Note       = note.Text;
            inv.CurrencyId = docCurr.Text.ToString();
            inv.Frequency  = frequency.Text;

            inv.Pol         = pol.Text;
            inv.Pod         = pod.Text;
            inv.ViaPort     = viaPort.Text;
            inv.Attention   = attention.Text;
            inv.TransmitDay = tsDay.Text;
            inv.Gp20        = 0; // SafeValue.SafeDecimal(gp20.Value, 0);
            inv.Gp40        = 0; //SafeValue.SafeDecimal(gp40.Value, 0);
            inv.Hc40        = 0; //SafeValue.SafeDecimal(hc40.Value, 0);
            inv.ContType    = contType.Text;
            inv.ContPrice   = SafeValue.SafeDecimal(contPrice.Value, 0);
            inv.ExRate      = SafeValue.SafeDecimal(exRate.Value, 1);
            inv.CreateUser  = HttpContext.Current.User.Identity.Name;
            inv.CreateDate  = DateTime.Now;
            inv.UpdateUser  = HttpContext.Current.User.Identity.Name;
            inv.UpdateDate  = DateTime.Now;
            try
            {
                C2.Manager.ORManager.StartTracking(inv, Wilson.ORMapper.InitialState.Inserted);
                C2.Manager.ORManager.PersistChanges(inv);
                C2Setup.SetNextNo(counterType, inv.QuoteNo);
            }
            catch
            {
            }
        }
        else
        {
            inv.Title   = title.Text;
            inv.PartyTo = SafeValue.SafeString(partyTo.Value, "");

            inv.ExpireDate = SafeValue.SafeDate(expireDt.Text, DateTime.Now);
            inv.Rmk        = rmk.Text;
            inv.Note       = note.Text;
            inv.CurrencyId = docCurr.Text.ToString();

            inv.Pol         = pol.Text;
            inv.Pod         = pod.Text;
            inv.ViaPort     = viaPort.Text;
            inv.Attention   = attention.Text;
            inv.TransmitDay = tsDay.Text;
            inv.Gp20        = 0; // SafeValue.SafeDecimal(gp20.Value, 0);
            inv.Gp40        = 0; //SafeValue.SafeDecimal(gp40.Value, 0);
            inv.Hc40        = 0; //SafeValue.SafeDecimal(hc40.Value, 0);
            inv.ContType    = contType.Text;
            inv.ContPrice   = SafeValue.SafeDecimal(contPrice.Value, 0);
            inv.ExRate      = SafeValue.SafeDecimal(exRate.Value, 1);
            inv.Frequency   = frequency.Text;

            inv.UpdateUser = HttpContext.Current.User.Identity.Name;
            inv.UpdateDate = DateTime.Now;
            try
            {
                Manager.ORManager.StartTracking(inv, InitialState.Updated);
                Manager.ORManager.PersistChanges(inv);
            }
            catch
            {
            }
        }
        Session["SeaApQuoteEditWhere"]      = "SequenceId=" + inv.SequenceId;
        this.dsApQuotation.FilterExpression = Session["SeaApQuoteEditWhere"].ToString();
        if (this.ASPxGridView1.GetRow(0) != null)
        {
            this.ASPxGridView1.StartEdit(0);
        }
    }
コード例 #30
0
    private void Save()
    {
        try
        {
            ASPxPageControl            pageControl = this.grid.FindEditFormTemplateControl("pageControl") as ASPxPageControl;
            ASPxTextBox                txtId       = pageControl.FindControl("txt_Id") as ASPxTextBox;
            string                     id          = SafeValue.SafeString(txtId.Text, "");
            Wilson.ORMapper.OPathQuery query       = new Wilson.ORMapper.OPathQuery(typeof(WhSORelease), "Id='" + id + "'");
            WhSORelease                obj         = C2.Manager.ORManager.GetObject(query) as WhSORelease;
            bool   isNew = false;
            string soNo  = "";
            if (obj == null)
            {
                obj   = new WhSORelease();
                isNew = true;
                soNo  = C2Setup.GetNextNo("SaleOrdersRelease");
            }
            ASPxTextBox txt_PartyRefNo = pageControl.FindControl("txt_PartyRefNo") as ASPxTextBox;
            obj.PartyRefNo = txt_PartyRefNo.Text;
            ASPxButtonEdit txt_PartyId = pageControl.FindControl("txt_PartyId") as ASPxButtonEdit;
            obj.PartyId = txt_PartyId.Text;
            ASPxDateEdit de_ReleaseDate = pageControl.FindControl("de_ReleaseDate") as ASPxDateEdit;
            obj.ReleaseDate = de_ReleaseDate.Date;
            ASPxButtonEdit txt_WarehouseId = pageControl.FindControl("txt_WarehouseId") as ASPxButtonEdit;
            obj.WarehouseId = txt_WarehouseId.Text;
            ASPxButtonEdit txt_SalesmanId = pageControl.FindControl("txt_SalesmanId") as ASPxButtonEdit;
            obj.SalesmanId = txt_SalesmanId.Text;
            ASPxButtonEdit txt_Currency = pageControl.FindControl("txt_Currency") as ASPxButtonEdit;
            obj.Currency = txt_Currency.Text;
            ASPxSpinEdit spin_ExRate = pageControl.FindControl("spin_ExRate") as ASPxSpinEdit;
            obj.ExRate = SafeValue.SafeDecimal(spin_ExRate.Value, 1);
            ASPxMemo txt_Remark = pageControl.FindControl("txt_Remark") as ASPxMemo;
            obj.Remark = txt_Remark.Text;


            string userId = HttpContext.Current.User.Identity.Name;
            if (isNew)
            {
                obj.CreateBy       = userId;
                obj.CreateDateTime = DateTime.Now;
                obj.ReleaseNo      = soNo.ToString();
                obj.StatusCode     = "USE";
                Manager.ORManager.StartTracking(obj, Wilson.ORMapper.InitialState.Inserted);
                Manager.ORManager.PersistChanges(obj);
                C2Setup.SetNextNo("SaleOrdersRelease", soNo);
            }
            else
            {
                obj.UpdateBy       = userId;
                obj.UpdateDateTime = DateTime.Now;
                Manager.ORManager.StartTracking(obj, Wilson.ORMapper.InitialState.Updated);
                Manager.ORManager.PersistChanges(obj);
            }
            Session["SORWhere"] = "ReleaseNo='" + obj.ReleaseNo + "'";
            this.dsWhSORelease.FilterExpression = Session["SORWhere"].ToString();
            if (this.grid.GetRow(0) != null)
            {
                this.grid.StartEdit(0);
            }
        }
        catch { }
    }