protected void grid1_CustomDataCallback(object sender, ASPxGridViewCustomDataCallbackEventArgs e) { try { if (list.Count > 0) { 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) { rate.ClientId = btn_ClientId.Text; rate.Price = list[i].amt; Manager.ORManager.StartTracking(rate, Wilson.ORMapper.InitialState.Inserted); Manager.ORManager.PersistChanges(rate); } } e.Result = "Success"; } else { e.Result = "Pls Select at least one Rate"; } } catch { } }
protected void grid1_CustomDataCallback(object sender, ASPxGridViewCustomDataCallbackEventArgs e) { if (Request.QueryString["quoteNo"] != null) { try { if (list.Count > 0) { string jobNo = SafeValue.SafeString(Request.QueryString["quoteNo"]); for (int i = 0; i < list.Count; i++) { int id = list[i].id; decimal price = list[i].price; decimal qty = list[i].qty; string unit = list[i].unit; 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) { rate.JobNo = jobNo; rate.Qty = qty; rate.Price = price; rate.Unit = unit; rate.LineType = "QUOTED"; Manager.ORManager.StartTracking(rate, Wilson.ORMapper.InitialState.Inserted); Manager.ORManager.PersistChanges(rate); } } e.Result = "Success"; } else { e.Result = "Pls Select at least one Rate"; } } catch { } } }
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 grid1_CustomDataCallback(object sender, ASPxGridViewCustomDataCallbackEventArgs e) { string par = e.Parameters; string no = SafeValue.SafeString(Request.QueryString["no"]); string jobNo = SafeValue.SafeString(Request.QueryString["jobNo"]); string status = SafeValue.SafeString(Request.QueryString["status"]); if (Request.QueryString["no"] != null) { try { if (par == "Cont") { #region Container if (status == "Quoted") { no = jobNo; } string sql = string.Format(@"select ContainerNo,ContainerType,(case when isnull(BillingRefNo,'')<>''then job.JobNo else '' end) as SubJobNo from CTM_JobDet1 det1 inner join CTM_Job job on det1.JobNo=job.JobNo where job.JobNo='{0}' or job.BillingRefNo='{0}'", no); DataTable dt = ConnectSql_mb.GetDataTable(sql); 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 subJobNo = SafeValue.SafeString(dt.Rows[a]["SubJobNo"]); for (int i = 0; i < list.Count; i++) { int n = SafeValue.SafeInt(ConnectSql_mb.ExecuteScalar(string.Format(@"select count(*) from job_cost where (JobNo='{0}' or JobNo='{1}') and LineType!='DP'", jobNo, no)), 0); n = n + 1; 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; string scope = SafeValue.SafeString(rate.BillScope, ""); string contSize = SafeValue.SafeString(rate.ContSize, ""); string str = ""; if (contType.Length > 2) { str = contType.Substring(0, 2); } decimal price = 0; if (status == "Rate") { if (rate.BillScope == "CONT") { insert_job_cost(rate, no, subJobNo, contNo, "", contType, contSize, str, par.ToUpper(), n); } } else { insert_job_cost(rate, jobNo, subJobNo, contNo, "", contType, contSize, str, par.ToUpper(), n); } if (subJobNo.Length > 0) { insert_job_cost(rate, subJobNo, "", contNo, "", contType, contSize, str, par.ToUpper(), n); } } } e.Result = "Success"; #endregion } if (par == "Job") { #region Job for (int i = 0; i < list.Count; i++) { int n = SafeValue.SafeInt(ConnectSql_mb.ExecuteScalar(string.Format(@"select count(*) from job_cost where JobNo='{0}' and LineType!='DP'", jobNo)), 0); n = n + 1; 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 (status == "Rate") { //if (rate.BillScope == "JOB") //{ insert_job_cost(rate, no, "", "", "", "", "", "", par.ToUpper(), n); //} } else { insert_job_cost(rate, jobNo, "", "", "", "", "", "", par.ToUpper(), n); } } e.Result = "Success"; #endregion } if (par == "Trip") { #region Trip if (status == "Quoted") { no = jobNo; } string sql = string.Format(@"select det2.Id,ChessisCode,job.JobNo,BillingRefNo,(case when isnull(BillingRefNo,'')<>''then job.JobNo else '' end) as SubJobNo from CTM_JobDet2 det2 inner join CTM_Job job on det2.JobNo=job.JobNo where job.JobNo='{0}' or job.BillingRefNo='{0}' and (Self_Ind='No' or isnull(Self_Ind,'')='')", no); DataTable dt = ConnectSql_mb.GetDataTable(sql); for (int a = 0; a < dt.Rows.Count; a++) { string tripId = SafeValue.SafeString(dt.Rows[a]["Id"]); string contNo = SafeValue.SafeString(dt.Rows[a]["ChessisCode"]); string subJobNo = SafeValue.SafeString(dt.Rows[a]["SubJobNo"]); for (int i = 0; i < list.Count; i++) { int n = SafeValue.SafeInt(ConnectSql_mb.ExecuteScalar(string.Format(@"select count(*) from job_cost where (JobNo='{0}' or JobNo='{1}') and LineType!='DP'", jobNo, no)), 0); n = n + 1; 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 (status == "Rate") { if (rate.BillScope.ToUpper() == "TRIP") { insert_job_cost(rate, no, subJobNo, contNo, tripId, "", "", "", par.ToUpper(), n); } } else { insert_job_cost(rate, jobNo, subJobNo, contNo, tripId, "", "", "", par.ToUpper(), n); } if (subJobNo.Length > 0) { insert_job_cost(rate, subJobNo, "", contNo, tripId, "", "", "", par.ToUpper(), n); } } } e.Result = "Success"; #endregion } } catch { } } }
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 { } } }