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); } }
private void InsertData(string jobType, string custJobNo, string custPic, string ves, string voy, string pol, string pod, DateTime eta, DateTime etd, DateTime bkgDate, string bkgTime, decimal wt, decimal m3, int qty, string pkgType, string rmk, string des, string frm, string to) { string runType = "LocalTpt"; C2.TptJob tj = new C2.TptJob(); tj.JobDate = DateTime.Today; tj.JobType = this.txt_type.Text; string jobNo = C2Setup.GetNextNo(tj.JobType, runType, tj.JobDate); tj.JobNo = jobNo; tj.JobType = jobType; string sql = "select CustId,Role from [User] where name='" + EzshipHelper.GetUserName() + "'"; DataTable dt = ConnectSql.GetTab(sql); string cust = ""; if (dt != null && dt.Rows.Count > 0 && dt.Rows[0][1].ToString().Equals("Client")) { cust = dt.Rows[0][0].ToString(); } tj.Cust = cust; tj.BkgRef = custJobNo; tj.CustPic = custPic; tj.CustEmail = ""; tj.CustDocNo = ""; tj.CustDocType = ""; tj.Vessel = ves; tj.Voyage = voy; tj.Pol = pol; tj.Pod = pod; tj.Eta = eta; tj.Etd = etd; tj.BlRef = ""; tj.BkgDate = bkgDate; tj.BkgTime = bkgTime; tj.JobRmk = rmk; tj.BkgQty = qty; tj.BkgPkgType = pkgType; tj.BkgWt = wt; tj.BkgM3 = m3; tj.PickFrm1 = frm; tj.DeliveryTo1 = to; tj.CargoMkg = ""; tj.CargoDesc = des; tj.JobProgress = "Booked"; tj.TptType = ""; tj.TripCode = ""; tj.Driver = ""; tj.VehicleNo = ""; tj.Qty = qty; tj.PkgType = pkgType; tj.Wt = wt; tj.M3 = m3; tj.FeeTpt = 0; tj.FeeLabour = 0; tj.FeeOt = 0; tj.FeeAdmin = 0; tj.FeeReimberse = 0; tj.FeeMisc = 0; tj.FeeTotal = tj.FeeTpt + tj.FeeLabour + tj.FeeOt + tj.FeeAdmin + tj.FeeReimberse + tj.FeeMisc; tj.FeeRemark = ""; 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); C2Setup.SetNextNo(tj.JobType, runType, jobNo, tj.JobDate); }
protected void 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; 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.UserId = HttpContext.Current.User.Identity.Name; tj.EntryDate = DateTime.Now; } tj.JobDate = jobDate.Date; 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 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; 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); 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 jobRmk = pageControl.FindControl("txt_JobRmk") as ASPxMemo; tj.JobRmk = jobRmk.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; 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); } else { tj.UpdateBy = EzshipHelper.GetUserName(); tj.UpdateDateTime = DateTime.Now; C2.Manager.ORManager.StartTracking(tj, Wilson.ORMapper.InitialState.Updated); C2.Manager.ORManager.PersistChanges(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); } } } catch (Exception ex) { throw new Exception(ex.Message); } }