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); }
private void insert_job_cost(C2.JobRate rate, string jobNo, string subJobNo, string contNo, string tripId, string contType, string contSize, string str, string type, int lineIndex) { 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.GstType = rate.GstType; cost.ContType = contType; cost.ChgCode = rate.ChgCode; cost.TripNo = tripId; cost.LineSource = "M"; cost.SubJobNo = subJobNo; if (rate.ChgCode.ToUpper().Equals("TRUCKING")) { cost.ChgCodeDe = rate.ChgCode; } else { cost.ChgCodeDe = rate.ChgCodeDe; } cost.Qty = rate.Qty; cost.Unit = rate.Unit; cost.LineType = type; cost.LocAmt = SafeValue.ChinaRound(1 * SafeValue.SafeDecimal(rate.Price, 0), 2); cost.LineIndex = lineIndex; //if (contSize == str) // { cost.Price = rate.Price; Manager.ORManager.StartTracking(cost, Wilson.ORMapper.InitialState.Inserted); Manager.ORManager.PersistChanges(cost); // } //if (contSize.Length == 0) //{ // cost.Price = rate.Price; // Manager.ORManager.StartTracking(cost, Wilson.ORMapper.InitialState.Inserted); // Manager.ORManager.PersistChanges(cost); //} }
protected void grid_CustomDataCallback(object sender, DevExpress.Web.ASPxGridView.ASPxGridViewCustomDataCallbackEventArgs e) { string par = e.Parameters; if (par == "OK") { string no = SafeValue.SafeString(Request.QueryString["no"]); string client = SafeValue.SafeString(Request.QueryString["client"]); string type = SafeValue.SafeString(Request.QueryString["type"]); if (Request.QueryString["no"] != null) { for (int i = 0; i < list.Count; i++) { string code = list[i].code; string des = list[i].des; decimal price = list[i].price; decimal qty = list[i].qty; string unit = list[i].unit; if (type == "Quoted") { #region Quotation JobRate rate = new JobRate(); rate.ChgCode = code; rate.ChgCodeDe = des; rate.Price = price; rate.JobNo = no; rate.Qty = qty; rate.ClientId = client; rate.Unit = unit; rate.RowCreateUser = EzshipHelper.GetUserName(); rate.RowCreateTime = DateTime.Now; rate.RowUpdateUser = EzshipHelper.GetUserName(); rate.RowUpdateTime = DateTime.Now; rate.ContSize = " "; rate.ContType = ""; rate.Remark = " "; rate.BillType = " "; rate.BillScope = " "; rate.LineType = "QUOTED"; Manager.ORManager.StartTracking(rate, Wilson.ORMapper.InitialState.Inserted); Manager.ORManager.PersistChanges(rate); #endregion } if (type == "Cost") { #region Job_Cost Job_Cost cost = new Job_Cost(); cost.ChgCode = code; cost.ChgCodeDe = des; cost.LineSource = "S"; cost.Price = price; cost.JobNo = no; cost.Qty = qty; cost.BillClass = " "; cost.Unit = unit; cost.RowCreateUser = EzshipHelper.GetUserName(); cost.RowCreateTime = DateTime.Now; cost.RowUpdateUser = EzshipHelper.GetUserName(); cost.RowUpdateTime = DateTime.Now; Manager.ORManager.StartTracking(cost, Wilson.ORMapper.InitialState.Inserted); Manager.ORManager.PersistChanges(cost); #endregion } } e.Result = "Success"; } } }
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 { } } }