private void InsertInv_det(int invId, string invNo, string mastType, int qty, decimal price, string sku, string arCode, string des, string lotNo)
    {
        XAArInvoiceDet det = new XAArInvoiceDet();

        det.ChgCode   = sku;
        det.ChgDes1   = des;
        det.AcCode    = arCode;
        det.Qty       = qty;
        det.Price     = price;
        det.DocId     = invId;
        det.DocNo     = invNo;
        det.DocLineNo = SafeValue.SafeInt(ConnectSql.ExecuteScalar("select count(*) from XAArInvoiceDet where DocId='" + invId + "'"), 0) + 1;

        det.DocType   = "IV";
        det.MastRefNo = "";
        det.JobRefNo  = lotNo;
        det.MastType  = mastType;
        det.AcSource  = "CR";
        det.Currency  = System.Configuration.ConfigurationManager.AppSettings["Currency"];
        det.ExRate    = 1;
        det.Gst       = 0;
        det.GstType   = "E";
        det.GstAmt    = 0;
        det.DocAmt    = SafeValue.ChinaRound(det.Qty * det.Price, 2);
        det.LocAmt    = det.DocAmt;

        C2.Manager.ORManager.StartTracking(det, Wilson.ORMapper.InitialState.Inserted);
        C2.Manager.ORManager.PersistChanges(det);
    }
Beispiel #2
0
        public static void CreateInv(string invN, int id, string docId, int n, string billType, string currency, decimal exrate)
        {
            string    sql       = string.Format(@"select * from job_cost where Id={0}", id);
            DataTable dt        = ConnectSql.GetTab(sql);
            string    sql_part1 = string.Format(@"insert into XAArInvoiceDet (DocId,DocNo,DocType,DocLineNo,AcCode,AcSource,ChgCode,ChgDes1,
GstType,Qty,Price,Unit,Currency,ExRate,Gst,GstAmt,DocAmt,LocAmt,LineLocAmt,MastRefNo,JobRefNo,MastType,JobCostId,LineIndex,ChgDes4,GroupBy,ChgDes2,ChgDes3)
values");

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                sql = "";
                decimal qty        = SafeValue.SafeDecimal(dt.Rows[i]["Qty"]);
                string  chgCodeId  = SafeValue.SafeString(dt.Rows[i]["ChgCode"]);
                string  chgCodeDes = SafeValue.SafeString(dt.Rows[i]["ChgCodeDes"]);
                decimal price      = SafeValue.SafeDecimal(dt.Rows[i]["Price"]);
                string  cntNo      = SafeValue.SafeString(dt.Rows[i]["ContNo"]);
                string  cntType    = SafeValue.SafeString(dt.Rows[i]["ContType"]);
                int     lineIndex  = SafeValue.SafeInt(dt.Rows[i]["LineIndex"], 0);
                string  jobNo      = SafeValue.SafeString(dt.Rows[i]["JobNo"]);
                string  gstType    = SafeValue.SafeString(dt.Rows[i]["GstType"]);
                string  unit       = SafeValue.SafeString(dt.Rows[i]["Unit"]);
                string  remark     = SafeValue.SafeString(dt.Rows[i]["Remark"]);
                string  groupBy    = SafeValue.SafeString(dt.Rows[i]["GroupBy"]);
                if (cntType.Length == 0)
                {
                    cntType = unit;
                }
                string    sql_chgCode = string.Format(@"select top 1 ChgcodeId,ChgcodeDes,GstP,GstTypeId,ChgTypeId,ArCode from XXChgCode where chgCodeId='{0}'", chgCodeId);
                DataTable dt_chgCode  = ConnectSql.GetTab(sql_chgCode);
                decimal   gst         = 0;
                string    chgTypeId   = "";
                string    arCode      = "";
                if (dt_chgCode.Rows.Count > 0)
                {
                    gst       = SafeValue.SafeDecimal(dt_chgCode.Rows[0]["GstP"]);
                    gstType   = SafeValue.SafeString(dt_chgCode.Rows[0]["GstTypeId"]);
                    chgTypeId = SafeValue.SafeString(dt_chgCode.Rows[0]["ChgTypeId"]);
                    arCode    = SafeValue.SafeString(dt_chgCode.Rows[0]["ArCode"]);
                }
                decimal amt    = SafeValue.ChinaRound(qty * SafeValue.SafeDecimal(price, 0), 2);
                decimal gstAmt = SafeValue.ChinaRound((amt * SafeValue.SafeDecimal(gst, 0)), 2);
                decimal docAmt = amt + gstAmt;
                decimal locAmt = SafeValue.ChinaRound(docAmt * exrate, 2);
                if (chgCodeDes.ToUpper().Equals("TRUCKING"))
                {
                    chgCodeDes += " " + billType.ToUpper();
                }
                string sql_part2 = string.Format(@"('{0}','{1}','IV','{2}','{18}','CR','{3}','{4}','{14}',{16},{5},'{9}','{21}',{22},{10},{11},{12},{13},0,'{6}','{7}','{8}',{15},{17},'{19}','{20}','','') select @@IDENTITY ", docId, invN, n + 1, chgCodeId, chgCodeDes, price, jobNo, cntNo, chgTypeId, cntType, gst, gstAmt, docAmt, locAmt, gstType, id, qty, lineIndex, arCode, remark, groupBy, currency, exrate);
                sql += sql.Length > 0 ? "," + sql_part2 : sql_part2;
            }
            if (sql.Length > 0)
            {
                sql = sql_part1 + sql;
                //throw new Exception(sql);
                int re = SafeValue.SafeInt(ConnectSql.ExecuteScalar(sql), 0);

                //UpdateMaster(SafeValue.SafeInt(docId, 0));
                UpdateLineId(id, re);
            }
        }
Beispiel #3
0
    protected void grid_RowInserting(object sender, DevExpress.Web.Data.ASPxDataInsertingEventArgs e)
    {
        e.NewValues["DocOwner"]  = "CLM";
        e.NewValues["DoType"]    = "IN3";
        e.NewValues["DocStatus"] = "Pending";
        e.NewValues["DocDate"]   = SafeValue.SafeDate(e.NewValues["DocDate"], DateTime.Now);
        if (S.Text(e.NewValues["DoType"]) == "OUT3")
        {
            string refNo = C2Setup.GetNextNo("", "CLM", S.Date(e.NewValues["DocDate"])); //SafeValue.SafeString(e.NewValues["RefNo"]);
            e.NewValues["BillNo"] = refNo;
            e.NewValues["DocNo"]  = refNo;
            C2Setup.SetNextNo("", "CLM", refNo, S.Date(e.NewValues["DocDate"]));
        }
        else
        {
            e.NewValues["BillNo"] = S.Text(e.NewValues["BillNo"]);
            e.NewValues["DocNo"]  = S.Text(e.NewValues["DocNo"]);
        }

        string  gst    = S.Text(e.NewValues["GstType"]);
        decimal qty    = S.Decimal(e.NewValues["Qty"]);
        decimal price  = S.Decimal(e.NewValues["Price"]);
        decimal tot    = SafeValue.ChinaRound(qty * price, 2);
        decimal gstamt = 0;

        if (gst == "S")
        {
            gstamt = SafeValue.ChinaRound(tot * S.Decimal(0.07), 2);
        }
        tot += gstamt;
        e.NewValues["Qty"]    = qty;
        e.NewValues["Price"]  = price;
        e.NewValues["GstAmt"] = gstamt;
        e.NewValues["DocAmt"] = tot;
    }
Beispiel #4
0
    protected void grid_InvDet_RowInserting(object sender, DevExpress.Web.Data.ASPxDataInsertingEventArgs e)
    {
        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;
        e.NewValues["MastType"]  = "";
        e.NewValues["MastRefNo"] = "0";
        e.NewValues["JobRefNo"]  = "0";
    }
    private string Save_Inline(int i, DevExpress.Web.ASPxGridView.ASPxGridViewCustomDataCallbackEventArgs e)
    {
        ASPxTextBox  txt_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;
        ASPxMemo     txt_Remark     = this.grid.FindRowCellTemplateControl(i, (DevExpress.Web.ASPxGridView.GridViewDataColumn) this.grid.Columns["Remark"], "txt_Remark") as ASPxMemo;
        ASPxTextBox  txt_GroupBy    = this.grid.FindRowCellTemplateControl(i, (DevExpress.Web.ASPxGridView.GridViewDataColumn) this.grid.Columns["GroupBy"], "txt_GroupBy") as ASPxTextBox;
        int          id             = SafeValue.SafeInt(txt_Id.Text, 0);
        string       contNo         = "";
        string       contType       = "";
        decimal      price          = SafeValue.SafeDecimal(spin_Price.Value);
        decimal      qty            = SafeValue.SafeDecimal(spin_Qty.Value);
        string       unit           = SafeValue.SafeString(txt_Unit.Text);
        string       code           = SafeValue.SafeString(cbb_ChgCode.Text);
        string       des            = SafeValue.SafeString(txt_ChgCodeDe.Text);
        int          lineIndex      = SafeValue.SafeInt(spin_LineIndex.Value, 0);
        string       remark         = SafeValue.SafeString(txt_Remark.Text);
        decimal      locAmt         = SafeValue.ChinaRound(qty * SafeValue.SafeDecimal(price, 0), 2);
        string       groupBy        = SafeValue.SafeString(txt_GroupBy.Text);
        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);
        return("Success");
    }
Beispiel #6
0
    protected void Grid1_RowInserting(object sender, DevExpress.Web.Data.ASPxDataInsertingEventArgs e)
    {
        string where = "FclLclInd='Lcl' and QuoteId='-1'";
        where       += " and PartyTo='" + SafeValue.SafeString(e.NewValues["PartyTo"], "") + "'";

        string sql_detCnt = "select max(QuoteLineNo) from SeaQuoteDet1 where " + where;
        int    lineNo     = SafeValue.SafeInt(C2.Manager.ORManager.ExecuteScalar(sql_detCnt), 0) + 1;

        e.NewValues["QuoteLineNo"] = lineNo;

        e.NewValues["QuoteId"]   = "-1";
        e.NewValues["FclLclInd"] = "Lcl";
        e.NewValues["PartyType"] = "C";
        e.NewValues["PartyTo"]   = "";

        e.NewValues["Status1"] = "BILL";

        if (SafeValue.SafeString(e.NewValues["GstType"], "") == "S")
        {
            e.NewValues["Gst"] = (decimal)0.07;
        }
        else
        {
            e.NewValues["Gst"] = (decimal)0;
        }
        e.NewValues["Amt"] = SafeValue.ChinaRound(SafeValue.SafeDecimal(e.NewValues["Price"], 0) * SafeValue.SafeDecimal(e.NewValues["Qty"], 1) * (1 + SafeValue.SafeDecimal(e.NewValues["Gst"], 0)), 2);
    }
    protected void grid_RowUpdating(object sender, DevExpress.Web.Data.ASPxDataUpdatingEventArgs e)
    {
        string    code        = SafeValue.SafeString(e.NewValues["ChgCode"]);
        string    sql_chgCode = string.Format(@"select top 1 ChgcodeId,ChgcodeDes,GstP,GstTypeId,ChgTypeId from XXChgCode where ChgcodeDes like '%{0}%'", code);
        DataTable dt_chgCode  = ConnectSql.GetTab(sql_chgCode);
        decimal   gst         = 0;
        string    gstType     = "";
        string    chgTypeId   = "";

        if (dt_chgCode.Rows.Count > 0)
        {
            gst       = SafeValue.SafeDecimal(dt_chgCode.Rows[0]["GstP"]);
            gstType   = SafeValue.SafeString(dt_chgCode.Rows[0]["GstTypeId"]);
            chgTypeId = SafeValue.SafeString(dt_chgCode.Rows[0]["ChgTypeId"]);
        }
        decimal price  = SafeValue.SafeDecimal(e.NewValues["Price"]);
        decimal amt    = SafeValue.ChinaRound(1 * SafeValue.SafeDecimal(price, 0), 2);
        decimal gstAmt = SafeValue.ChinaRound((amt * SafeValue.SafeDecimal(gst, 0)), 2);
        decimal docAmt = amt + gstAmt;
        decimal locAmt = SafeValue.ChinaRound(docAmt * SafeValue.SafeDecimal(1, 1), 2);

        e.NewValues["LocAmt"]    = locAmt;
        e.NewValues["LineType"]  = SafeValue.SafeString(e.NewValues["LineType"]);
        e.NewValues["ChgCodeDe"] = SafeValue.SafeString(e.NewValues["ChgCodeDe"]);
        e.NewValues["Remark"]    = SafeValue.SafeString(e.NewValues["Remark"]);
        e.NewValues["ContNo"]    = SafeValue.SafeString(e.NewValues["ContNo"]);
        e.NewValues["ContType"]  = SafeValue.SafeString(e.NewValues["ContType"]);
    }
    protected void grid_CostDet_RowUpdating(object sender, DevExpress.Web.Data.ASPxDataUpdatingEventArgs e)
    {
        e.NewValues["ChgCode"]      = SafeValue.SafeString(e.NewValues["ChgCode"]);
        e.NewValues["ChgCodeDes"]   = SafeValue.SafeString(e.NewValues["ChgCodeDes"]);
        e.NewValues["Unit"]         = SafeValue.SafeString(e.NewValues["Unit"]);
        e.NewValues["SaleQty"]      = SafeValue.SafeDecimal(e.NewValues["SaleQty"], 1);
        e.NewValues["SalePrice"]    = SafeValue.SafeDecimal(e.NewValues["SalePrice"], 0);
        e.NewValues["SaleCurrency"] = SafeValue.SafeString(e.NewValues["SaleCurrency"]);
        e.NewValues["SaleExRate"]   = SafeValue.SafeDecimal(e.NewValues["SaleExRate"], 1);
        e.NewValues["Remark"]       = SafeValue.SafeString(e.NewValues["Remark"]);
        e.NewValues["DocNo"]        = SafeValue.SafeString(e.NewValues["DocNo"]);
        e.NewValues["Status2"]      = SafeValue.SafeString(e.NewValues["Status2"]);
        e.NewValues["Status3"]      = SafeValue.SafeString(e.NewValues["Status3"]);
        e.NewValues["Status4"]      = SafeValue.SafeString(e.NewValues["Status4"]);
        e.NewValues["CostDate"]     = SafeValue.SafeDate(e.NewValues["CostDate"], new DateTime(1753, 01, 01));

        decimal amt    = SafeValue.ChinaRound(SafeValue.SafeDecimal(e.NewValues["SaleQty"], 0) * SafeValue.SafeDecimal(e.NewValues["SalePrice"], 0), 2);
        decimal gstAmt = 0;//SafeValue.ChinaRound((amt * SafeValue.SafeDecimal(e.NewValues["Gst"], 0)), 2);
        decimal docAmt = amt + gstAmt;
        decimal locAmt = SafeValue.ChinaRound(docAmt * SafeValue.SafeDecimal(e.NewValues["SaleExRate"], 1), 2);

        e.NewValues["SaleDocAmt"]    = locAmt;
        e.NewValues["RowUpdateUser"] = EzshipHelper.GetUserName();
        e.NewValues["RowUpdateTime"] = DateTime.Now;
    }
 protected void grid_wh_RowInserting(object sender, DevExpress.Web.Data.ASPxDataInsertingEventArgs e)
 {
     if (SafeValue.SafeString(e.NewValues["BookingNo"]) == "")
     {
         throw new Exception("Pls enter the Lot No");
     }
     e.NewValues["RefNo"] = SafeValue.SafeString(e.NewValues["RefNo"]);
     if (SafeValue.SafeDecimal(e.NewValues["LengthPack"]) == 0 && SafeValue.SafeDecimal(e.NewValues["WidthPack"]) == 0 && SafeValue.SafeDecimal(e.NewValues["HeightPack"]) == 0)
     {
         e.NewValues["VolumeOrig"] = SafeValue.SafeDecimal(e.NewValues["VolumeOrig"]);
     }
     else
     {
         e.NewValues["VolumeOrig"] = SafeValue.ChinaRound(SafeValue.SafeDecimal(e.NewValues["LengthPack"]) * SafeValue.SafeDecimal(e.NewValues["WidthPack"]) * SafeValue.SafeDecimal(e.NewValues["HeightPack"]), 3);
     }
     e.NewValues["CargoStatus"]   = SafeValue.SafeString(e.NewValues["CargoStatus"]);
     e.NewValues["LandStatus"]    = SafeValue.SafeString(e.NewValues["LandStatus"]);
     e.NewValues["DgClass"]       = SafeValue.SafeString(e.NewValues["DgClass"]);
     e.NewValues["DamagedStatus"] = SafeValue.SafeString(e.NewValues["DamagedStatus"]);
     e.NewValues["ContNo"]        = SafeValue.SafeString(e.NewValues["ContNo"]);
     e.NewValues["HblNo"]         = SafeValue.SafeString(e.NewValues["HblNo"]);
     e.NewValues["BookingNo"]     = SafeValue.SafeString(e.NewValues["BookingNo"]);
     e.NewValues["Qty"]           = SafeValue.SafeDecimal(e.NewValues["Qty"]);
     e.NewValues["OpsType"]       = SafeValue.SafeString(e.NewValues["OpsType"]);
     e.NewValues["UomCode"]       = SafeValue.SafeString(e.NewValues["UomCode"]);
     e.NewValues["Weight"]        = SafeValue.SafeDecimal(e.NewValues["Weight"]);
     e.NewValues["Volume"]        = SafeValue.SafeDecimal(e.NewValues["Volume"]);
     e.NewValues["SkuCode"]       = SafeValue.SafeString(e.NewValues["SkuCode"]);
     e.NewValues["QtyOrig"]       = SafeValue.SafeDecimal(e.NewValues["QtyOrig"]);
     e.NewValues["PackTypeOrig"]  = SafeValue.SafeString(e.NewValues["PackTypeOrig"]);
     e.NewValues["WeightOrig"]    = SafeValue.SafeDecimal(e.NewValues["WeightOrig"]);
     e.NewValues["PackQty"]       = SafeValue.SafeDecimal(e.NewValues["PackQty"]);
     e.NewValues["TripId"]        = SafeValue.SafeInt(e.NewValues["TripId"], 0);
     e.NewValues["TripIndex"]     = SafeValue.SafeString(e.NewValues["TripIndex"]);
 }
Beispiel #10
0
    protected void grid_Transport_RowUpdating(object sender, DevExpress.Web.Data.ASPxDataUpdatingEventArgs e)
    {
        e.NewValues["EventDate"] = SafeValue.SafeDate(e.NewValues["EventDate"], new DateTime(1753, 1, 1));
        string eventType = SafeValue.SafeString(e.NewValues["EventType"], "");

        e.NewValues["LineSource"] = "M";
        e.NewValues["ChgCode"]    = eventType;
        e.NewValues["ChgCodeDe"]  = eventType;
        e.NewValues["EventType"]  = eventType;
        e.NewValues["ExpiryDate"] = SafeValue.SafeDate(e.NewValues["ExpiryDate"], new DateTime(1753, 1, 1));
        e.NewValues["DriverCode"] = SafeValue.SafeString(e.NewValues["DriverCode"], "");
        decimal amt = SafeValue.SafeDecimal(e.NewValues["Price"], 0);

        e.NewValues["Price"]     = amt;
        e.NewValues["LocAmt"]    = SafeValue.ChinaRound(1 * SafeValue.SafeDecimal(e.NewValues["Price"], 0), 2);
        e.NewValues["VehicleNo"] = SafeValue.SafeString(e.NewValues["VehicleNo"], "");
        e.NewValues["DocAmt"]    = SafeValue.SafeDecimal(e.NewValues["DocAmt"], 0);
        e.NewValues["Remark"]    = SafeValue.SafeString(e.NewValues["Remark"], "");
        string jobNo  = SafeValue.SafeString(e.NewValues["JobNo"], "");
        string contNo = SafeValue.SafeString(e.NewValues["ContNo"], "");

        e.NewValues["JobNo"]    = jobNo;
        e.NewValues["ContNo"]   = contNo;
        e.NewValues["TripNo"]   = SafeValue.SafeString(e.NewValues["TripNo"], "");
        e.NewValues["TripType"] = SafeValue.SafeString(e.NewValues["TripType"], "");
    }
    protected void grid_InvDet_RowUpdating(object sender, DevExpress.Web.Data.ASPxDataUpdatingEventArgs e)
    {
        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";
        }
    }
Beispiel #12
0
    private void insert_cost(int i, string no, string subJobNo, string type, string contNo, string contType, string tripId, string code, string des, decimal price, decimal gst, string gstType, string unit)
    {
        Job_Cost c = new Job_Cost();

        c.LineIndex  = i;
        c.TripNo     = tripId;
        c.ChgCode    = code;
        c.ChgCodeDe  = des;
        c.ContNo     = contNo;
        c.ContType   = contType;
        c.Price      = price;
        c.JobNo      = no;
        c.Qty        = 1;
        c.LineType   = type;
        c.GstType    = gstType;
        c.LineSource = "M";
        c.LineStatus = "";
        c.Unit       = unit;
        c.CurrencyId = "SGD";
        c.SubJobNo   = subJobNo;
        decimal amt    = SafeValue.ChinaRound(1 * SafeValue.SafeDecimal(price, 0), 2);
        decimal gstAmt = SafeValue.ChinaRound((amt * SafeValue.SafeDecimal(gst, 0)), 2);
        decimal docAmt = amt;
        decimal locAmt = SafeValue.ChinaRound(docAmt * SafeValue.SafeDecimal(1, 1), 2);

        c.DocAmt        = docAmt;
        c.LocAmt        = locAmt;
        c.RowCreateUser = EzshipHelper.GetUserName();
        c.RowCreateTime = DateTime.Now;
        c.RowUpdateUser = EzshipHelper.GetUserName();
        c.RowUpdateTime = DateTime.Now;

        Manager.ORManager.StartTracking(c, Wilson.ORMapper.InitialState.Inserted);
        Manager.ORManager.PersistChanges(c);
    }
Beispiel #13
0
    protected void grid_PORDet_RowUpdating(object sender, DevExpress.Web.Data.ASPxDataUpdatingEventArgs e)
    {
        ASPxPageControl pageControl = this.grid_WhPoR.FindEditFormTemplateControl("pageControl") as ASPxPageControl;

        if (SafeValue.SafeString(e.NewValues["Product"], "").Length < 1)
        {
            e.Cancel = true;
            throw new Exception("Pls select the Product");
        }
        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;
        e.NewValues["UpdateBy"]       = HttpContext.Current.User.Identity.Name;
        e.NewValues["UpdateDateTime"] = DateTime.Now;
        ASPxButtonEdit txt_WarehouseId = pageControl.FindControl("txt_WarehouseId") as ASPxButtonEdit;

        e.NewValues["WareHouseId"] = SafeValue.SafeString(txt_WarehouseId.Text);
    }
    protected void Page_Init(object sender, EventArgs e)
    {
        if (!IsCallback)
        {
            B28.Text = "30.00";
            C23.Text = "105.00";
            if (Request.Params["id"] != null)
            {
                string id = SafeValue.SafeString(Request.Params["id"]);
                txt_Id.Text = id;
                string    sql = string.Format("select (Select SaleDocAmt from  CostDet where ParentId='{0}' and ChgCode='ORG006') as C23,(Select SaleDocAmt from  CostDet where ParentId='{0}' and ChgCode='ORG007') as C24,(select Volumne from JobInfo where JobNo=(select RefNo from Cost where SequenceId='{0}')) as Volumn,* from CostDet where ParentId='{0}'", id);
                DataTable dt  = C2.Manager.ORManager.GetDataSet(sql).Tables[0];
                decimal   m   = SafeValue.SafeDecimal(dt.Rows[0]["Volumn"], 0);
                B15.Text = SafeValue.SafeString(dt.Rows[0]["Volumn"]);

                C15.Value = SafeValue.ChinaRound(m - m * SafeValue.SafeDecimal(0.2), 0);
                D15.Value = SafeValue.ChinaRound(m * SafeValue.SafeDecimal(6.5), 0);
                B16.Value = SafeValue.ChinaRound(m / SafeValue.SafeDecimal(35.312), 2);
                C16.Value = SafeValue.ChinaRound((m - m * SafeValue.SafeDecimal(0.2)) * SafeValue.SafeDecimal(6.5), 0);
                D16.Value = SafeValue.ChinaRound(m * SafeValue.SafeDecimal(6.5) / SafeValue.SafeDecimal(2.2), 0);
                D18.Value = SafeValue.ChinaRound((m - m * SafeValue.SafeDecimal(0.2)) * 1, 3);
                C20.Value = SafeValue.ChinaRound(m * SafeValue.SafeDecimal(1.2), 2);
                C23.Value = SafeValue.SafeString(dt.Rows[0]["C23"], "0");
                C24.Value = SafeValue.SafeDecimal(dt.Rows[0]["C24"], 0);
                C25.Value = SafeValue.ChinaRound(270 + m * SafeValue.SafeDecimal(1.2) + SafeValue.SafeDecimal(C23.Value) + SafeValue.SafeDecimal(C24.Value), 2);//170+m * 1.2+parseFloat(C23.GetText())+parseFloat(C24.GetText())
                //C28.Text = SafeValue.SafeString(FormatNumber(m / 35.312, 2) * B28_ * E27_);
            }
        }
    }
Beispiel #15
0
        private void InsertJob_Cost(string jobNo, string chgCode, string chgDes, string mastType,
                                    decimal qty, decimal price, string itemCode, string lotNo, string skuCode, DateTime nextBillDate, string id)
        {
            Job_Cost cost = new Job_Cost();

            cost.RelaId        = id;
            cost.BillStartDate = nextBillDate;
            cost.JobNo         = jobNo;
            cost.CurrencyId    = System.Configuration.ConfigurationManager.AppSettings["Currency"];
            cost.ExRate        = new decimal(1.0);
            cost.ContNo        = "";
            cost.ContType      = "";
            cost.ChgCode       = chgCode;
            cost.ChgCodeDe     = chgDes;
            if (itemCode.Length > 0)
            {
                cost.Remark = lotNo + "/" + itemCode;
            }
            if (skuCode.Length > 0)
            {
                cost.Remark = lotNo + "/" + skuCode;
            }
            cost.LineSource    = "S";
            cost.Qty           = qty;
            cost.Unit          = "";
            cost.LineType      = "STORAGE";
            cost.LocAmt        = SafeValue.ChinaRound(qty * SafeValue.SafeDecimal(price, 0), 2);
            cost.Price         = price;
            cost.RowCreateTime = DateTime.Now;
            cost.RowCreateUser = "******";
            cost.RowUpdateTime = DateTime.Now;
            cost.RowUpdateUser = "******";
            Manager.ORManager.StartTracking(cost, Wilson.ORMapper.InitialState.Inserted);
            Manager.ORManager.PersistChanges(cost);
        }
Beispiel #16
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);
    }
Beispiel #17
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);
 }
Beispiel #18
0
    private void InsertPl_Det(int docId, string docNo, string docType, int index, string sku, string lotNo, string des, int qty, decimal price, string cur, decimal exRate, decimal gst, string soNo, string doNo, string mastType)
    {
        try
        {
            C2.XAApPayableDet det = new C2.XAApPayableDet();
            det.DocId     = docId;
            det.DocLineNo = index;
            det.DocNo     = docNo;
            det.DocType   = docType;
            det.AcCode    = SafeValue.SafeString(ConnectSql.ExecuteScalar(string.Format("select ApCode from ref_product where Code='{0}'", sku)), System.Configuration.ConfigurationManager.AppSettings["ItemApCode"]);
            det.AcSource  = "DB";
            det.MastRefNo = soNo;
            det.JobRefNo  = lotNo;
            det.MastType  = mastType;
            det.SplitType = "";



            det.ChgCode  = sku;
            det.ChgDes1  = des;
            det.ChgDes2  = "";
            det.ChgDes3  = "";
            det.Price    = price;
            det.Qty      = qty;
            det.Unit     = "";
            det.Currency = cur;
            det.ExRate   = 1;
            det.Gst      = gst;
            if (det.ExRate == 0)
            {
                det.ExRate = 1;
            }
            if (det.Gst > 0)
            {
                det.GstType = "S";
            }
            else if (det.Currency == System.Configuration.ConfigurationManager.AppSettings["Currency"])
            {
                det.GstType = "E";
            }
            else
            {
                det.GstType = "Z";
            }
            decimal amt    = SafeValue.ChinaRound(det.Qty * det.Price, 2);
            decimal gstAmt = SafeValue.ChinaRound((amt * det.Gst), 2);
            decimal docAmt = amt + gstAmt;
            decimal locAmt = SafeValue.ChinaRound(docAmt * det.ExRate, 2);
            det.GstAmt = gstAmt;
            det.DocAmt = docAmt;
            det.LocAmt = locAmt;
            C2.Manager.ORManager.StartTracking(det, Wilson.ORMapper.InitialState.Inserted);
            C2.Manager.ORManager.PersistChanges(det);
        }
        catch
        {
        }
    }
    protected void ASPxGridView1_RowUpdating(object sender, DevExpress.Web.Data.ASPxDataUpdatingEventArgs e)
    {
        e.NewValues["ChgCode"]    = SafeValue.SafeString(e.NewValues["ChgCode"]);
        e.NewValues["ChgCodeDes"] = SafeValue.SafeString(e.NewValues["ChgCodeDes"]);
        e.NewValues["Remark"]     = SafeValue.SafeString(e.NewValues["Remark"]);

        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);
    }
Beispiel #20
0
    protected void Grid_Costing_RowInserting(object sender, DevExpress.Web.Data.ASPxDataInsertingEventArgs e)
    {
        ASPxGridView g    = sender as ASPxGridView;
        ASPxTextBox  refN = grid1.FindEditFormTemplateControl("TXT0") as ASPxTextBox;

        e.NewValues["RefNo"]      = refN.Text;
        e.NewValues["JobNo"]      = refN.Text;
        e.NewValues["JobType"]    = "SE";
        e.NewValues["SaleDocAmt"] = SafeValue.ChinaRound(SafeValue.SafeDecimal(e.NewValues["SaleQty"], 0) * SafeValue.SafeDecimal(e.NewValues["SalePrice"], 0), 2);
    }
Beispiel #21
0
 protected void grid_RowUpdating(object sender, DevExpress.Web.Data.ASPxDataUpdatingEventArgs e)
 {
     if (SafeValue.SafeInt(e.NewValues["Person"], 0) == 0)
         throw new Exception("Employee can not be null !!!");
     e.NewValues["Person"] = SafeValue.SafeInt(e.NewValues["Person"], 0);
     decimal hours = SafeValue.SafeDecimal(e.NewValues["Hour"]);
     decimal tim = SafeValue.SafeDecimal(e.NewValues["Time"]);
     decimal rate = SafeValue.SafeDecimal(e.NewValues["HoursRate"]);
     e.NewValues["TotalAmt"] = SafeValue.ChinaRound(hours * rate * tim, 2);
 }
Beispiel #22
0
        public static decimal get_weight(int houseId, decimal skuQty)
        {
            string  sql      = string.Format(@"select sum(SkuQty) from Dimension where HouseId={0}", houseId);
            decimal totalQty = SafeValue.SafeDecimal(ConnectSql_mb.ExecuteScalar(sql));

            sql = string.Format(@"select sum(TotalWt) from Dimension where HouseId={0}", houseId);
            decimal totalWt = SafeValue.SafeDecimal(ConnectSql_mb.ExecuteScalar(sql));
            decimal res     = SafeValue.ChinaRound((totalWt / totalQty) * skuQty, 3);

            return(res);
        }
Beispiel #23
0
    protected void grid_wh_RowInserting(object sender, DevExpress.Web.Data.ASPxDataInsertingEventArgs e)
    {
        ASPxTextBox  txt_JobNo   = this.grid_job.FindEditFormTemplateControl("txt_JobNo") as ASPxTextBox;
        ASPxComboBox cbb_JobType = this.grid_job.FindEditFormTemplateControl("cbb_JobType") as ASPxComboBox;

        if (cbb_JobType.Text == "GR")
        {
            e.NewValues["CargoType"] = "IN";
            e.NewValues["RefNo"]     = txt_JobNo.Text;
        }
        if (cbb_JobType.Text == "DO")
        {
            e.NewValues["CargoType"] = "OUT";
        }
        if (SafeValue.SafeString(e.NewValues["BookingNo"]) == "")
        {
            throw new Exception("Pls enter the Lot No");
        }
        if (SafeValue.SafeInt(e.NewValues["QtyOrig"], 0) <= 0)
        {
            throw new Exception("Pls enter the Actual's Qty");
        }
        e.NewValues["JobType"] = SafeValue.SafeString(cbb_JobType.Value);

        e.NewValues["JobNo"] = txt_JobNo.Text;
        ASPxButtonEdit btn_ClientId = this.grid_job.FindEditFormTemplateControl("btn_ClientId") as ASPxButtonEdit;

        e.NewValues["ClientId"] = btn_ClientId.Text;
        if (SafeValue.SafeDecimal(e.NewValues["LengthPack"]) == 0 && SafeValue.SafeDecimal(e.NewValues["WidthPack"]) == 0 && SafeValue.SafeDecimal(e.NewValues["HeightPack"]) == 0)
        {
            e.NewValues["VolumeOrig"] = SafeValue.SafeDecimal(e.NewValues["VolumeOrig"]);
        }
        else
        {
            e.NewValues["VolumeOrig"] = SafeValue.ChinaRound(SafeValue.SafeDecimal(e.NewValues["LengthPack"]) * SafeValue.SafeDecimal(e.NewValues["WidthPack"]) * SafeValue.SafeDecimal(e.NewValues["HeightPack"]), 3);
        }
        e.NewValues["LandStatus"]    = SafeValue.SafeString(e.NewValues["LandStatus"]);
        e.NewValues["DgClass"]       = SafeValue.SafeString(e.NewValues["DgClass"]);
        e.NewValues["DamagedStatus"] = SafeValue.SafeString(e.NewValues["DamagedStatus"]);
        e.NewValues["ContNo"]        = SafeValue.SafeString(e.NewValues["ContNo"]);
        e.NewValues["HblNo"]         = SafeValue.SafeString(e.NewValues["HblNo"]);
        e.NewValues["BookingNo"]     = SafeValue.SafeString(e.NewValues["BookingNo"]);
        e.NewValues["Qty"]           = SafeValue.SafeDecimal(e.NewValues["Qty"]);
        e.NewValues["OpsType"]       = SafeValue.SafeString(e.NewValues["OpsType"]);
        e.NewValues["UomCode"]       = SafeValue.SafeString(e.NewValues["UomCode"]);
        e.NewValues["Weight"]        = SafeValue.SafeDecimal(e.NewValues["Weight"]);
        e.NewValues["Volume"]        = SafeValue.SafeDecimal(e.NewValues["Volume"]);
        e.NewValues["SkuCode"]       = SafeValue.SafeString(e.NewValues["SkuCode"]);
        e.NewValues["QtyOrig"]       = SafeValue.SafeDecimal(e.NewValues["QtyOrig"]);
        e.NewValues["PackTypeOrig"]  = SafeValue.SafeString(e.NewValues["PackTypeOrig"]);
        e.NewValues["WeightOrig"]    = SafeValue.SafeDecimal(e.NewValues["WeightOrig"]);
        e.NewValues["PackQty"]       = SafeValue.SafeDecimal(e.NewValues["PackQty"]);
    }
    protected void ASPxGridView1_RowInserting(object sender, DevExpress.Web.Data.ASPxDataInsertingEventArgs e)
    {
        ASPxButtonEdit doNo = ASPxGridView1.FindEditFormTemplateControl("txt_DoNo") as ASPxButtonEdit;

        e.NewValues["JobType"]    = "OUT";
        e.NewValues["RefNo"]      = doNo.Text;
        e.NewValues["ChgCode"]    = SafeValue.SafeString(e.NewValues["ChgCode"]);
        e.NewValues["ChgCodeDes"] = SafeValue.SafeString(e.NewValues["ChgCodeDes"]);
        e.NewValues["Remark"]     = SafeValue.SafeString(e.NewValues["Remark"]);
        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);
    }
    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";
    }
Beispiel #26
0
    protected void grid_Cost_RowInserting(object sender, DevExpress.Web.Data.ASPxDataInsertingEventArgs e)
    {
        ASPxTextBox refNo = this.grid_ref.FindEditFormTemplateControl("txt_RefN") as ASPxTextBox;

        e.NewValues["JobType"]    = "AI";
        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);
    }
Beispiel #27
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.ChinaRound(SafeValue.SafeDecimal(e.NewValues["Price"], 0) * SafeValue.SafeDecimal(e.NewValues["Qty"], 1) * (1 + SafeValue.SafeDecimal(e.NewValues["Gst"], 0)), 2);
 }
Beispiel #28
0
 protected void Grid_Costing_RowUpdating(object sender, DevExpress.Web.Data.ASPxDataUpdatingEventArgs e)
 {
     e.NewValues["SplitType"]    = SafeValue.SafeString(e.NewValues["SplitType"]);
     e.NewValues["ChgCode"]      = SafeValue.SafeString(e.NewValues["ChgCode"]);
     e.NewValues["ChgCodeDes"]   = SafeValue.SafeString(e.NewValues["ChgCodeDes"]);
     e.NewValues["SaleQty"]      = SafeValue.SafeDecimal(e.NewValues["SaleQty"], 0);
     e.NewValues["SalePrice"]    = SafeValue.SafeDecimal(e.NewValues["SalePrice"], 0);
     e.NewValues["SaleDocAmt"]   = SafeValue.ChinaRound(SafeValue.SafeDecimal(e.NewValues["SaleQty"], 0) * SafeValue.SafeDecimal(e.NewValues["SalePrice"], 0), 2);
     e.NewValues["SaleCurrency"] = SafeValue.SafeString(e.NewValues["SaleCurrency"]);
     e.NewValues["Remark"]       = SafeValue.SafeString(e.NewValues["Remark"], "");
     e.NewValues["Salesman"]     = SafeValue.SafeString(e.NewValues["Salesman"], "");
     e.NewValues["DocNo"]        = SafeValue.SafeString(e.NewValues["DocNo"], "");
 }
    protected void grid_Cost_RowInserting(object sender, DevExpress.Web.Data.ASPxDataInsertingEventArgs e)
    {
        ASPxTextBox sequenceID = this.ASPxGridView1.FindEditFormTemplateControl("txt_Oid") as ASPxTextBox;

        ASPxTextBox refNo = this.ASPxGridView1.FindEditFormTemplateControl("txt_DocNo") as ASPxTextBox;

        e.NewValues["QuoteNo"]    = 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);
    }
Beispiel #30
0
    private void CreateInv(string invN, int id, string docId)
    {
        string    sql       = string.Format(@"select * from job_cost where Id={0}", id);
        DataTable dt        = ConnectSql.GetRemoteTab(sql);
        string    sql_part1 = string.Format(@"insert into XAArInvoiceDet (DocId,DocNo,DocType,DocLineNo,AcCode,AcSource,ChgCode,ChgDes1,
GstType,Qty,Price,Unit,Currency,ExRate,Gst,GstAmt,DocAmt,LocAmt,LineLocAmt,MastRefNo,JobRefNo,MastType,JobCostId)
values");

        for (int i = 0; i < dt.Rows.Count; i++)
        {
            sql = "";
            string    chgCodeId   = SafeValue.SafeString(dt.Rows[i]["ChgCode"]);
            string    chgCodeDes  = SafeValue.SafeString(dt.Rows[i]["ChgCodeDes"]);
            decimal   price       = SafeValue.SafeDecimal(dt.Rows[i]["Price"]);
            string    cntNo       = SafeValue.SafeString(dt.Rows[i]["ContNo"]);
            string    cntType     = SafeValue.SafeString(dt.Rows[i]["ContType"]);
            string    jobNo       = SafeValue.SafeString(dt.Rows[i]["JobNo"]);
            string    billType    = SafeValue.SafeString(cbb_BillType.Text, "");
            string    sql_chgCode = string.Format(@"select top 1 ChgcodeId,ChgcodeDes,GstP,GstTypeId,ChgTypeId from XXChgCode where chgCodeId='{0}'", chgCodeId);
            DataTable dt_chgCode  = ConnectSql.GetTab(sql_chgCode);
            decimal   gst         = 0;
            string    gstType     = "";
            string    chgTypeId   = "";
            if (dt_chgCode.Rows.Count > 0)
            {
                gst        = SafeValue.SafeDecimal(dt_chgCode.Rows[0]["GstP"]);
                gstType    = SafeValue.SafeString(dt_chgCode.Rows[0]["GstTypeId"]);
                chgTypeId  = SafeValue.SafeString(dt_chgCode.Rows[0]["ChgTypeId"]);
                chgCodeDes = SafeValue.SafeString(dt_chgCode.Rows[0]["ChgCodeDes"]);
            }
            decimal amt    = SafeValue.ChinaRound(1 * SafeValue.SafeDecimal(price, 0), 2);
            decimal gstAmt = SafeValue.ChinaRound((amt * SafeValue.SafeDecimal(gst, 0)), 2);
            decimal docAmt = amt + gstAmt;
            decimal locAmt = SafeValue.ChinaRound(docAmt * SafeValue.SafeDecimal(1, 1), 2);
            if (chgCodeDes.ToUpper().Equals("TRUCKING"))
            {
                chgCodeDes += " " + billType.ToUpper();
            }
            string sql_part2 = string.Format(@"('{0}','{1}','IV','{2}','','CR','{3}','{4}','{14}',1,{5},'{9}','SGD',1,{10},{11},{12},{13},0,'{6}','{7}','{8}',{15}) select @@IDENTITY ", docId, invN, i + 1, chgCodeId, chgCodeDes, price, jobNo, cntNo, chgTypeId, cntType, gst, gstAmt, docAmt, locAmt, gstType, id);
            sql += sql.Length > 0 ? "," + sql_part2 : sql_part2;
        }
        if (sql.Length > 0)
        {
            sql = sql_part1 + sql;
            int re = SafeValue.SafeInt(ConnectSql.ExecuteScalar(sql), 0);

            UpdateMaster(SafeValue.SafeInt(docId, 0));
            UpdateLineId(id, re);
        }
    }