protected void grid1_RowUpdating(object sender, DevExpress.Web.Data.ASPxDataUpdatingEventArgs e) { e.NewValues["UpdateBy"] = HttpContext.Current.User.Identity.Name.ToUpper(); e.NewValues["UpdateDateTime"] = DateTime.Now; e.NewValues["BkgRefNo"] = SafeValue.SafeString(e.NewValues["BkgRefNo"]); e.NewValues["HblNo"] = SafeValue.SafeString(e.NewValues["HblNo"]); e.NewValues["CustomerId"] = SafeValue.SafeString(e.NewValues["CustomerId"]); e.NewValues["ShipperId"] = SafeValue.SafeString(e.NewValues["ShipperId"]); e.NewValues["ShipperName"] = SafeValue.SafeString(e.NewValues["ShipperName"]); e.NewValues["ShipperContact"] = SafeValue.SafeString(e.NewValues["ShipperContact"]); e.NewValues["ShipperFax"] = SafeValue.SafeString(e.NewValues["ShipperFax"]); e.NewValues["ShipperTel"] = SafeValue.SafeString(e.NewValues["ShipperTel"]); e.NewValues["ShipperEmail"] = SafeValue.SafeString(e.NewValues["ShipperEmail"]); e.NewValues["Pol"] = SafeValue.SafeString(e.NewValues["Pol"]); e.NewValues["PlaceLoadingName"] = SafeValue.SafeString(e.NewValues["PlaceLoadingName"]); e.NewValues["FrtTerm"] = SafeValue.SafeString(e.NewValues["FrtTerm"]); e.NewValues["Pod"] = SafeValue.SafeString(e.NewValues["Pod"]); e.NewValues["PlaceDischargeName"] = SafeValue.SafeString(e.NewValues["PlaceDischargeName"]); e.NewValues["PreCarriage"] = SafeValue.SafeString(e.NewValues["PreCarriage"]); e.NewValues["PlaceDeliveryId"] = SafeValue.SafeString(e.NewValues["PlaceDeliveryId"]); e.NewValues["PlaceDeliveryname"] = SafeValue.SafeString(e.NewValues["PlaceDeliveryname"]); e.NewValues["PlaceDeliveryTerm"] = SafeValue.SafeString(e.NewValues["PlaceDeliveryTerm"]); e.NewValues["PlaceReceiveId"] = SafeValue.SafeString(e.NewValues["PlaceReceiveId"]); e.NewValues["PlaceReceiveName"] = SafeValue.SafeString(e.NewValues["PlaceReceiveName"]); e.NewValues["PlaceReceiveTerm"] = SafeValue.SafeString(e.NewValues["PlaceReceiveTerm"]); e.NewValues["ShipOnBoardInd"] = SafeValue.SafeString(e.NewValues["ShipOnBoardInd"]); e.NewValues["ShipOnBoardDate"] = SafeValue.SafeDate(e.NewValues["ShipOnBoardDate"], new DateTime(1753, 01, 01)); e.NewValues["ExpressBl"] = SafeValue.SafeString(e.NewValues["ExpressBl"]); e.NewValues["CustRefNo"] = SafeValue.SafeString(e.NewValues["CustRefNo"]); e.NewValues["ServiceType"] = SafeValue.SafeString(e.NewValues["ServiceType"]); e.NewValues["SurrenderBl"] = SafeValue.SafeString(e.NewValues["SurrenderBl"]); e.NewValues["Note2"] = SafeValue.SafeString(e.NewValues["Note2"]); EzshipLog.Log(SafeValue.SafeString(e.NewValues["JobNo"]), SafeValue.SafeString(e.NewValues["JobNo"]), "Direct", "Update"); }
protected void grid_ref_CustomDataCallback(object sender, ASPxGridViewCustomDataCallbackEventArgs e) { string s = e.Parameters; ASPxPageControl pageControl = this.grid_ref.FindEditFormTemplateControl("pageControl") as ASPxPageControl; ASPxTextBox masterId = this.grid_ref.FindEditFormTemplateControl("txt_Id") as ASPxTextBox; string userId = HttpContext.Current.User.Identity.Name; ASPxLabel closeIndStr = this.grid_ref.FindEditFormTemplateControl("lab_CloseInd") as ASPxLabel; ASPxTextBox txt_RefN = this.grid_ref.FindEditFormTemplateControl("txt_RefN") as ASPxTextBox; ASPxButton btn = this.grid_ref.FindControl("btn_CloseJob") as ASPxButton; string sql = string.Format("select StatusCode from air_ref where Id={0}", masterId.Text); string statusCode = SafeValue.SafeString(C2.Manager.ORManager.ExecuteScalar(sql)); if (s == "VoidMaster") { #region void master string sql_cnt = string.Format("select count(SequenceId) from XAArInvoiceDet where MastType='AI' and MastRefNo='{0}' ", txt_RefN.Text); int cnt = SafeValue.SafeInt(C2.Manager.ORManager.ExecuteScalar(sql_cnt), 0); if (cnt > 0) { e.Result = "Billing"; return; } if (statusCode == "CNL") { sql = string.Format("update air_ref set StatusCode='USE' where RefNo='{0}'", txt_RefN.Text); string sql1 = string.Format("update air_job set StatusCode='USE' where RefNo='{0}'", txt_RefN.Text); int res = Manager.ORManager.ExecuteCommand(sql); int res1 = Manager.ORManager.ExecuteCommand(sql1); if (res > 0 && res1 > 0) { EzshipLog.Log(txt_RefN.Text, "", "AI", "Unvoid"); e.Result = "Success"; //btn.Text = "Close Job"; //closeIndStr.Text = "C"; } else { e.Result = "Fail"; } } else { string refType = "AI"; bool closeByEst = EzshipHelper.GetCloseEstInd(txt_RefN.Text, refType); if (closeByEst) { sql = string.Format("update air_ref set StatusCode='CNL' where RefNo='{0}'", txt_RefN.Text); string sql1 = string.Format("update air_job set StatusCode='CNL' where RefNo='{0}'", txt_RefN.Text); int res = Manager.ORManager.ExecuteCommand(sql); int res1 = Manager.ORManager.ExecuteCommand(sql1); if (res > 0 && res1 > 0) { EzshipLog.Log(txt_RefN.Text, "", "AI", "Void"); e.Result = "Success"; //btn.Text = "Close Job"; //closeIndStr.Text = "C"; } else { e.Result = "Fail"; } } else { e.Result = "NoMatch"; } } #endregion } if (s == "CloseJob") { #region close job if (statusCode == "CLS") { sql = string.Format("update air_ref set StatusCode='USE' where RefNo='{0}'", txt_RefN.Text); string sql1 = string.Format("update air_job set StatusCode='USE' where RefNo='{0}'", txt_RefN.Text); int res = Manager.ORManager.ExecuteCommand(sql); int res1 = Manager.ORManager.ExecuteCommand(sql1); if (res > 0 && res1 > 0) { EzshipLog.Log(txt_RefN.Text, "", "AI", "Open"); e.Result = "Success"; //btn.Text = "Close Job"; //closeIndStr.Text = "N"; } else { e.Result = "Fail"; } } else { string refType = "AI"; bool closeByEst = EzshipHelper.GetCloseEstInd(txt_RefN.Text, refType); if (closeByEst) { sql = string.Format("update air_ref set StatusCode='CLS', CloseDate='{0}' ,CloseUser='******' where RefNo='{2}'", DateTime.Today.ToString("yyyy-MM-dd"), userId, txt_RefN.Text); string sql1 = string.Format("update air_job set StatusCode='CLS' where RefNo='{0}'", txt_RefN.Text); int res = Manager.ORManager.ExecuteCommand(sql); int res1 = Manager.ORManager.ExecuteCommand(sql1); if (res > 0 && res1 > 0) { EzshipLog.Log(txt_RefN.Text, "", "AI", "Close"); e.Result = "Success"; //btn.Text = "Open Job"; //closeIndStr.Text = "Y"; } else { e.Result = "Fail"; } } else { e.Result = "NoMatch"; } } #endregion } }
protected void grid_CustomDataCallback(object sender, ASPxGridViewCustomDataCallbackEventArgs e) { string s = e.Parameters; if (s == "Save") { e.Result = SaveLc(); ASPxComboBox cmb_Type = grid.FindEditFormTemplateControl("cmb_Type") as ASPxComboBox; ASPxTextBox txt_LcNo = this.grid.FindEditFormTemplateControl("txt_LcNo") as ASPxTextBox; string type = SafeValue.SafeString(cmb_Type.Text); bool isAddLog = false; if (type == "Confirmed") { ASPxButtonEdit btn_BankCode = grid.FindEditFormTemplateControl("btn_BankCode") as ASPxButtonEdit; string bankCode = SafeValue.SafeString(btn_BankCode.Text); string sql = string.Format(@"select LoanFund from Lc_BankFunds where BankCode='{0}'", bankCode); decimal loanFund = SafeValue.SafeDecimal(C2.Manager.ORManager.ExecuteScalar(sql)); ASPxSpinEdit spin_LcAmount = grid.FindEditFormTemplateControl("spin_LcAmount") as ASPxSpinEdit; decimal amount = SafeValue.SafeDecimal(spin_LcAmount.Text); sql = string.Format(@"select sum(LoanFund) from Ref_LC where BankCode='{0}'", bankCode); decimal totalAmount = SafeValue.SafeDecimal(C2.Manager.ORManager.ExecuteScalar(sql)); decimal space = SafeValue.SafeDecimal((loanFund - (amount + totalAmount))); if (space < 0) { e.Result = "No Enough Amount"; } } if (cmb_Type.Text == SafeValue.SafeString(ConnectSql.ExecuteScalar("Select RefType from LcActivity where RefNo='" + txt_LcNo.Text + "'"))) { } else { isAddLog = true; } if (isAddLog) { if (type == "IMPORT LC") { EzshipLog.Activity(txt_LcNo.Text, "", "IMPORT LC", "RECEIVING"); } if (type == "EXPORT LC") { EzshipLog.Activity(txt_LcNo.Text, "", "EXPORT LC", "ISSUING"); } if (type == "STANDBY LC") { EzshipLog.Activity(txt_LcNo.Text, "", "EXPORT LC", "COLLECTION"); } if (type == "BANK GUARANTEE") { EzshipLog.Activity(txt_LcNo.Text, "", "BANK GUARANTEE", "REMARK"); } if (type == "SHIPPING GUARANTEE") { EzshipLog.Activity(txt_LcNo.Text, "", "SHIPPING GUARANTEE", "REMARK"); } if (type == "OTHERS") { EzshipLog.Activity(txt_LcNo.Text, "", "OTHERS", "OTHERS"); } } } }
protected string SaveLc() { try { ASPxTextBox txt_LcNo = grid.FindEditFormTemplateControl("txt_LcNo") as ASPxTextBox; ASPxTextBox txt_Id = grid.FindEditFormTemplateControl("txt_Id") as ASPxTextBox; string id = SafeValue.SafeString(txt_Id.Text, ""); Wilson.ORMapper.OPathQuery query = new Wilson.ORMapper.OPathQuery(typeof(RefLc), "Id='" + id + "'"); RefLc lc = C2.Manager.ORManager.GetObject(query) as RefLc; ASPxDateEdit date_AppDate = grid.FindEditFormTemplateControl("date_AppDate") as ASPxDateEdit; bool isNew = false; //const string runType = "DOOUT"; string lcNo = ""; if (lc == null) { lc = new RefLc(); isNew = true; lcNo = C2Setup.GetNextNo("", "LetterOfCredit", date_AppDate.Date); lc.LcAppDate = date_AppDate.Date; } ASPxComboBox cmb_Type = grid.FindEditFormTemplateControl("cmb_Type") as ASPxComboBox; lc.LcType = cmb_Type.Text; ASPxDateEdit date_LcExpirtDate = grid.FindEditFormTemplateControl("date_LcExpirtDate") as ASPxDateEdit; lc.LcExpirtDate = date_LcExpirtDate.Date; //Main Info ASPxTextBox txt_TempNo = grid.FindEditFormTemplateControl("txt_TempNo") as ASPxTextBox; lc.LcTempNo = txt_TempNo.Text; ASPxTextBox txt_LcRefNo = grid.FindEditFormTemplateControl("txt_LcRefNo") as ASPxTextBox; lc.LcRef = txt_LcRefNo.Text; ASPxTextBox txt_LcExpirtPlace = grid.FindEditFormTemplateControl("txt_LcExpirtPlace") as ASPxTextBox; lc.LcExpirtPlace = txt_LcExpirtPlace.Text; ASPxButtonEdit txt_EntityCode = grid.FindEditFormTemplateControl("txt_EntityCode") as ASPxButtonEdit; lc.LcEntityCode = txt_EntityCode.Text; ASPxTextBox txt_EntityName = grid.FindEditFormTemplateControl("txt_EntityName") as ASPxTextBox; lc.LcEntityName = txt_EntityName.Text; ASPxMemo memo_EntityAddress = grid.FindEditFormTemplateControl("memo_EntityAddress") as ASPxMemo; lc.LcEntityAddress = memo_EntityAddress.Text; ASPxButtonEdit btn_BeneCode = grid.FindEditFormTemplateControl("btn_BeneCode") as ASPxButtonEdit; lc.LcBeneCode = btn_BeneCode.Text; ASPxTextBox txt_LcBeneName = grid.FindEditFormTemplateControl("txt_LcBeneName") as ASPxTextBox; lc.LcBeneName = txt_LcBeneName.Text; ASPxMemo memo_BeneAddress = grid.FindEditFormTemplateControl("memo_BeneAddress") as ASPxMemo; lc.LcBeneAddress = memo_BeneAddress.Text; ASPxButtonEdit btn_BankCode = grid.FindEditFormTemplateControl("btn_BankCode") as ASPxButtonEdit; lc.BankCode = btn_BankCode.Text; ASPxTextBox txt_BankName = grid.FindEditFormTemplateControl("txt_BankName") as ASPxTextBox; lc.BankName = txt_BankName.Text; ASPxMemo memo_BankAddress = grid.FindEditFormTemplateControl("memo_BankAddress") as ASPxMemo; lc.BankAddress = memo_BankAddress.Text; ASPxTextBox txt_Branch = grid.FindEditFormTemplateControl("txt_Branch") as ASPxTextBox; lc.BankBranch = txt_Branch.Text; ASPxTextBox txt_BankRef = grid.FindEditFormTemplateControl("txt_BankRef") as ASPxTextBox; lc.BankRef = txt_BankRef.Text; ASPxSpinEdit spin_BankTenor = grid.FindEditFormTemplateControl("spin_BankTenor") as ASPxSpinEdit; lc.BankTenor = SafeValue.SafeInt(spin_BankTenor.Text, 0); ASPxSpinEdit spin_LcAmount = grid.FindEditFormTemplateControl("spin_LcAmount") as ASPxSpinEdit; lc.LcAmount = SafeValue.SafeDecimal(spin_LcAmount.Value, 1); ASPxButtonEdit currency = grid.FindEditFormTemplateControl("txt_Currency") as ASPxButtonEdit; lc.LcCurrency = currency.Text; ASPxSpinEdit exRate = grid.FindEditFormTemplateControl("spin_ExRate") as ASPxSpinEdit; lc.LcExRate = SafeValue.SafeDecimal(exRate.Value, 1); ASPxTextBox txt_LcMode = grid.FindEditFormTemplateControl("txt_LcMode") as ASPxTextBox; lc.LcMode = txt_LcMode.Text; ASPxComboBox cmb_Status = grid.FindEditFormTemplateControl("cmb_Status") as ASPxComboBox; lc.StatusCode = cmb_Status.Text; string userId = HttpContext.Current.User.Identity.Name; if (isNew) { lc.CreateBy = userId; lc.CreateDateTime = DateTime.Now; lc.LcNo = lcNo; Manager.ORManager.StartTracking(lc, Wilson.ORMapper.InitialState.Inserted); Manager.ORManager.PersistChanges(lc); C2Setup.SetNextNo("", "LetterOfCredit", lcNo, date_AppDate.Date); } else { lc.UpdateBy = userId; lc.UpdateDateTime = DateTime.Now; bool isAddLog = false; if (lc.StatusCode == SafeValue.SafeString(ConnectSql.ExecuteScalar("Select StatusCode from Ref_LC where LcNo='" + lc.LcNo + "'"))) { } else { isAddLog = true; } Manager.ORManager.StartTracking(lc, Wilson.ORMapper.InitialState.Updated); Manager.ORManager.PersistChanges(lc); if (isAddLog) { EzshipLog.Log(lc.LcNo, "", lc.LcType, lc.StatusCode); } } Session["RefLC"] = "LcNo='" + lc.LcNo + "'"; this.dsLc.FilterExpression = Session["RefLC"].ToString(); if (this.grid.GetRow(0) != null) { this.grid.StartEdit(0); } return(lc.LcNo); } catch { } return(""); }
protected void grid_CustomDataCallback(object sender, ASPxGridViewCustomDataCallbackEventArgs e) { string s = e.Parameters; if (s == "Save") { ASPxButtonEdit btn_BankCode = grid.FindEditFormTemplateControl("btn_BankCode") as ASPxButtonEdit; string bankCode = SafeValue.SafeString(btn_BankCode.Text); ASPxSpinEdit spin_LcAmount = grid.FindEditFormTemplateControl("spin_LcAmount") as ASPxSpinEdit; decimal lcAmount = SafeValue.SafeDecimal(spin_LcAmount.Value, 1); ASPxTextBox txt_Id = this.grid.FindEditFormTemplateControl("txt_Id") as ASPxTextBox; string id = SafeValue.SafeString(txt_Id.Text); if (VilaLC(bankCode, lcAmount, id) && lcAmount != 0) { e.Result = "Fail!No Enough Credit Limit"; return; } else { e.Result = SaveLc(); ASPxComboBox cmb_Type = grid.FindEditFormTemplateControl("cmb_Type") as ASPxComboBox; ASPxTextBox txt_LcNo = this.grid.FindEditFormTemplateControl("txt_LcNo") as ASPxTextBox; string type = SafeValue.SafeString(cmb_Type.Text); bool isAddLog = false; if (cmb_Type.Text == SafeValue.SafeString(ConnectSql.ExecuteScalar("Select LcType from Ref_LC where LcNo='" + txt_LcNo.Text + "'"))) { } else { isAddLog = true; } if (isAddLog) { if (type == "IMPORT LC") { EzshipLog.Activity(txt_LcNo.Text, "", "IMPORT LC", "RECEIVING"); } if (type == "EXPORT LC") { EzshipLog.Activity(txt_LcNo.Text, "", "EXPORT LC", "ISSUING"); } if (type == "STANDBY LC") { EzshipLog.Activity(txt_LcNo.Text, "", "EXPORT LC", "COLLECTION"); } if (type == "BANK GUARANTEE") { EzshipLog.Activity(txt_LcNo.Text, "", "BANK GUARANTEE", "REMARK"); } if (type == "SHIPPING GUARANTEE") { EzshipLog.Activity(txt_LcNo.Text, "", "SHIPPING GUARANTEE", "REMARK"); } if (type == "OTHERS") { EzshipLog.Activity(txt_LcNo.Text, "", "OTHERS", "OTHERS"); } } } } }
protected void grd_Do_CustomDataCallback(object sender, ASPxGridViewCustomDataCallbackEventArgs e) { string s = e.Parameters; ASPxPageControl pageControl = this.grd_Do.FindEditFormTemplateControl("pageControl") as ASPxPageControl; ASPxTextBox id = grd_Do.FindEditFormTemplateControl("txt_Id") as ASPxTextBox; ASPxTextBox txt_DoNo = this.grd_Do.FindEditFormTemplateControl("txt_DoNo") as ASPxTextBox; ASPxButtonEdit txt_WareHouseId = grd_Do.FindEditFormTemplateControl("txt_WareHouseId") as ASPxButtonEdit; ASPxButtonEdit txt_PartyId = grd_Do.FindEditFormTemplateControl("txt_PartyId") as ASPxButtonEdit; ASPxTextBox txt_PartyName = grd_Do.FindEditFormTemplateControl("txt_PartyName") as ASPxTextBox; if (s == "Save") { #region Save if (txt_PartyId.Text.Trim() == "") { e.Result = "Fail"; return; } ASPxComboBox doStatus = grd_Do.FindEditFormTemplateControl("cmb_Status") as ASPxComboBox; if (doStatus.Text == "Confirmed") { //check purchase price and sell price string sql1 = string.Format(@"select count(id) from wh_transdet where dono='{0}' and DoType='po'", txt_DoNo.Text); if (SafeValue.SafeInt(ConnectSql.ExecuteScalar(sql1), 0) == 0) { e.Result = "NO SKU"; return; } sql1 = string.Format(@"select (case when Price=0 then 0 else 1 end) Result from Wh_TransDet where dono='{0}' and DoType='po'", txt_DoNo.Text); DataTable tab = ConnectSql.GetTab(sql1); for (int i = 0; i < tab.Rows.Count; i++) { if (SafeValue.SafeInt(tab.Rows[i]["Result"], 0) == 0) { e.Result = "No Price"; return; } } } if (txt_DoNo.Text.Length > 4) { SavePo(); e.Result = "";//update old one } else { e.Result = SavePo();// new one } return; #endregion } //string sql = "select Count(*) from Wh_TransDet where DoNo='" + SafeValue.SafeString(txt_DoNo.Text) + "' and (JobStatus='Draft' or JobStatus='Waiting')"; // int cnt = SafeValue.SafeInt(C2.Manager.ORManager.ExecuteScalar(sql), 0); //if (cnt == 0) // { if (s == "CloseJob") { #region close job string sql = "select DoStatus from Wh_Trans where DoNo='" + txt_DoNo.Text + "'"; string closeInd = SafeValue.SafeString(C2.Manager.ORManager.ExecuteScalar(sql), "USE");// if (closeInd == "Closed") { sql = string.Format("update Wh_Trans set DoStatus='Draft' where DoNo='{0}'", txt_DoNo.Text); int res = Manager.ORManager.ExecuteCommand(sql); if (res > 0) { EzshipLog.Log(txt_DoNo.Text, "", "PO", "Open Job"); e.Result = "Success"; } else { e.Result = "Fail"; } } else { sql = string.Format("update Wh_Trans set DoStatus='Closed' where DoNo='{0}'", txt_DoNo.Text); int res = Manager.ORManager.ExecuteCommand(sql); if (res > 0) { EzshipLog.Log(txt_DoNo.Text, "", "PO", "Closed Job"); e.Result = "Success"; } else { e.Result = "Fail"; } } #endregion } //} //else //{ // e.Result = "NotClose"; //} if (s == "Void") { #region void master string sql_cnt = string.Format("select count(SequenceId) from XAArInvoiceDet where MastType='WH' and MastRefNo='{0}'", txt_DoNo.Text); int cnt = SafeValue.SafeInt(C2.Manager.ORManager.ExecuteScalar(sql_cnt), 0); if (cnt > 0) { e.Result = "Billing"; return; } string sql = "select StatusCode from Wh_Trans where DoNo='" + txt_DoNo.Text + "'"; string closeInd = SafeValue.SafeString(C2.Manager.ORManager.ExecuteScalar(sql), "N");// closeIndStr.Text; if (closeInd == "CNL") { sql = string.Format("update Wh_Trans set StatusCode='USE' where DoNo='{0}'", txt_DoNo.Text); int res = Manager.ORManager.ExecuteCommand(sql); if (res > 0) { e.Result = "Success"; } else { e.Result = "Fail"; } } else { sql = string.Format("update Wh_Trans set StatusCode='CNL' where DoNo='{0}'", txt_DoNo.Text); int res = Manager.ORManager.ExecuteCommand(sql); if (res > 0) { e.Result = "Success"; } else { e.Result = "Fail"; } } #endregion } else if (s == "Confirm") { #region Confirm if (txt_PartyId.Text.Trim() == "") { e.Result = "Fail"; return; } string sql = "select StatusCode from Wh_Trans where DoNo='" + txt_DoNo.Text + "'"; string closeInd = SafeValue.SafeString(C2.Manager.ORManager.ExecuteScalar(sql), "Draft");// if (closeInd == "Draft") { bool closeByEst = true;//EzshipHelper.GetCloseEstInd(refN.Text, refType); if (closeByEst) { sql = string.Format("update Wh_Trans set DoStatus='Confirmed',UpdateBy='{1}',UpdateDateTime='{2}' where DoNo='{0}'", txt_DoNo.Text, EzshipHelper.GetUserName(), DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); int res = Manager.ORManager.ExecuteCommand(sql); if (res > 0) { //string poNo = AddPurchase(tab, txt_DoNo.Text, txt_PartyId.Text, txt_PartyName.Text, txt_WareHouseId.Text); //TransferToStock(txt_DoNo.Text, "PO"); EzshipLog.Log(txt_DoNo.Text, "", "PO", "Confirmed"); e.Result = "Success"; } else { e.Result = "Fail"; } } else { e.Result = "NoMatch"; } } else { } #endregion } else if (s == "CreatePO") { #region Create PO string sql = string.Format(@"select * from Wh_TransDet where DoNo='{0}' and Qty1>0", txt_DoNo.Text); DataTable tab = ConnectSql.GetTab(sql); if (tab.Rows.Count > 0) { sql = string.Format(@"select count(*) from (select sum(Qty1) as TotalQty1,mast.DoNo from Wh_TransDet det inner join Wh_Trans mast on det.DoNo=mast.DoNo and mast.DoType='BP' group by mast.DoNo) as tab_bp left join (select sum(Qty1) as TotalQty2,BlanketNo from Wh_TransDet det inner join Wh_Trans mast on det.DoNo=mast.DoNo and mast.DoType='PO' group by BlanketNo) as tab_so on tab_so.BlanketNo=tab_bp.DoNo where TotalQty1-TotalQty2=0 and BlanketNo='{0}'", txt_DoNo.Text); int res = Manager.ORManager.ExecuteCommand(sql); if (res > 0) { e.Result = "The purchase qty has been complete"; return; } string poNo = AddPurchase(tab, txt_DoNo.Text, txt_PartyId.Text, txt_PartyName.Text, txt_WareHouseId.Text); e.Result = "Success! " + "Purcharse Order No is " + poNo; } else { e.Result = "NO Qty"; } #endregion } }
protected string SaveJob() { try { ASPxPageControl pageControl = this.grid_Issue.FindEditFormTemplateControl("pageControl_Hbl") as ASPxPageControl; ASPxTextBox DoNo = grid_Issue.FindEditFormTemplateControl("txt_DoNo") as ASPxTextBox; ASPxTextBox txt_Id = grid_Issue.FindEditFormTemplateControl("txt_Id") as ASPxTextBox; string pId = SafeValue.SafeString(txt_Id.Text, ""); Wilson.ORMapper.OPathQuery query = new Wilson.ORMapper.OPathQuery(typeof(JobInfo), "Id='" + pId + "'"); JobInfo job = C2.Manager.ORManager.GetObject(query) as JobInfo; ASPxDateEdit issueDate = grid_Issue.FindEditFormTemplateControl("date_IssueDate") as ASPxDateEdit; bool isNew = false; //const string runType = "DOOUT"; string issueN = ""; if (job == null) { job = new JobInfo(); isNew = true; job.JobType = "SRTemp"; //issueN = C2Setup.GetNextNo("", "JobOrder", issueDate.Date); issueN = "SRTemp-01"; job.JobDate = issueDate.Date; } job.Attribute = "Temp"; ASPxDateEdit doDate = grid_Issue.FindEditFormTemplateControl("date_IssueDate") as ASPxDateEdit; job.JobDate = doDate.Date; ASPxComboBox cmb_Status = grid_Issue.FindEditFormTemplateControl("cmb_Status") as ASPxComboBox; job.JobStage = SafeValue.SafeString(cmb_Status.Value); ASPxComboBox cmb_JobType = grid_Issue.FindEditFormTemplateControl("cmb_JobType") as ASPxComboBox; job.JobType = SafeValue.SafeString(cmb_JobType.Value); //Main Info ASPxMemo remark = grid_Issue.FindEditFormTemplateControl("txt_Remark") as ASPxMemo; job.Remark = remark.Text; ASPxButtonEdit currency = grid_Issue.FindEditFormTemplateControl("txt_Currency") as ASPxButtonEdit; job.Currency = currency.Text; ASPxSpinEdit exRate = grid_Issue.FindEditFormTemplateControl("spin_ExRate") as ASPxSpinEdit; job.ExRate = SafeValue.SafeDecimal(exRate.Value, 1); ASPxComboBox payTerm = grid_Issue.FindEditFormTemplateControl("cmb_PayTerm") as ASPxComboBox; job.PayTerm = payTerm.Text; ASPxDateEdit date_ExpiryDate = grid_Issue.FindEditFormTemplateControl("date_ExpiryDate") as ASPxDateEdit; job.ExpiryDate = date_ExpiryDate.Date; ASPxMemo txt_PackRemark = grid_Issue.FindEditFormTemplateControl("txt_PackRemark") as ASPxMemo; job.PackRmk = txt_PackRemark.Text; ASPxMemo txt_MoveRemark = grid_Issue.FindEditFormTemplateControl("txt_MoveRemark") as ASPxMemo; job.MoveRmk = txt_MoveRemark.Text; ASPxButtonEdit txt_WareHouseId = grid_Issue.FindEditFormTemplateControl("txt_WareHouseId") as ASPxButtonEdit; job.WareHouseId = txt_WareHouseId.Text; ASPxSpinEdit spin_Volumne = grid_Issue.FindEditFormTemplateControl("spin_Volumne") as ASPxSpinEdit; job.Volumne = SafeValue.SafeDecimal(spin_Volumne.Value); ASPxMemo memo_Description = grid_Issue.FindEditFormTemplateControl("memo_Description") as ASPxMemo; job.ItemDes = memo_Description.Text; ASPxTextBox memo_Volumn = grid_Issue.FindEditFormTemplateControl("memo_Volumn") as ASPxTextBox; job.VolumneRmk = memo_Description.Text; ASPxSpinEdit spin_HeadCount = grid_Issue.FindEditFormTemplateControl("spin_HeadCount") as ASPxSpinEdit; job.HeadCount = SafeValue.SafeInt(spin_HeadCount.Value, 0); ASPxDateEdit date_Pack = grid_Issue.FindEditFormTemplateControl("date_Pack") as ASPxDateEdit; job.PackDate = date_Pack.Date; ASPxComboBox cmb_Via = grid_Issue.FindEditFormTemplateControl("cmb_Via") as ASPxComboBox; job.ViaWh = cmb_Via.Text; ASPxDateEdit date_StorageStartDate = grid_Issue.FindEditFormTemplateControl("date_StorageStartDate") as ASPxDateEdit; job.StorageStartDate = date_StorageStartDate.Date; ASPxSpinEdit spin_StorageFreeDays = grid_Issue.FindEditFormTemplateControl("spin_StorageFreeDays") as ASPxSpinEdit; job.StorageFreeDays = SafeValue.SafeInt(spin_StorageFreeDays.Value, 0); ASPxSpinEdit spin_STotalDays = grid_Issue.FindEditFormTemplateControl("spin_STotalDays") as ASPxSpinEdit; job.StorageTotalDays = Helper.Safe.SafeInt(spin_STotalDays.Value); ASPxTextBox txt_TripNo = grid_Issue.FindEditFormTemplateControl("txt_TripNo") as ASPxTextBox; job.TripNo = txt_TripNo.Text; ASPxDateEdit date_MoveDate = grid_Issue.FindEditFormTemplateControl("date_MoveDate") as ASPxDateEdit; job.MoveDate = date_MoveDate.Date; ASPxSpinEdit spin_Charges = grid_Issue.FindEditFormTemplateControl("spin_Charges") as ASPxSpinEdit; job.Charges = SafeValue.SafeDecimal(spin_Charges.Value); ASPxButtonEdit btn_PortOfEntry = grid_Issue.FindEditFormTemplateControl("btn_PortOfEntry") as ASPxButtonEdit; job.EntryPort = btn_PortOfEntry.Text; ASPxDateEdit date_Eta = grid_Issue.FindEditFormTemplateControl("date_Eta") as ASPxDateEdit; job.Eta = date_Eta.Date; ASPxTextBox txt_TruckNo = grid_Issue.FindEditFormTemplateControl("txt_TruckNo") as ASPxTextBox; job.TruckNo = txt_TruckNo.Text; //Additional ASPxComboBox cmb_WorkStatus = grid_Issue.FindEditFormTemplateControl("cmb_WorkStatus") as ASPxComboBox; job.WorkStatus = SafeValue.SafeString(cmb_WorkStatus.Value); //Quotation ASPxHtmlEditor txt_Attention1 = pageControl.FindControl("txt_Attention1") as ASPxHtmlEditor; if (txt_Attention1 != null) { job.Attention1 = txt_Attention1.Html; } ASPxHtmlEditor txt_Attention2 = pageControl.FindControl("txt_Attention2") as ASPxHtmlEditor; if (txt_Attention2 != null) { job.Attention2 = txt_Attention2.Html; } ASPxHtmlEditor txt_Attention3 = pageControl.FindControl("txt_Attention3") as ASPxHtmlEditor; if (txt_Attention3 != null) { job.Attention3 = txt_Attention3.Html; } ASPxHtmlEditor txt_Attention4 = pageControl.FindControl("txt_Attention4") as ASPxHtmlEditor; if (txt_Attention4 != null) { job.Attention4 = txt_Attention4.Html; } job.WorkStatus = "Pending"; ASPxComboBox cmb_SalesId = grid_Issue.FindEditFormTemplateControl("cmb_SalesId") as ASPxComboBox; job.Value4 = cmb_SalesId.Text; string userId = HttpContext.Current.User.Identity.Name; if (isNew) { job.CreateBy = userId; job.CreateDateTime = DateTime.Now; job.UpdateBy = userId; job.UpdateDateTime = DateTime.Now; job.JobNo = issueN; Manager.ORManager.StartTracking(job, Wilson.ORMapper.InitialState.Inserted); Manager.ORManager.PersistChanges(job); // C2Setup.SetNextNo("", "JobOrder", issueN, issueDate.Date); } else { job.UpdateBy = userId; job.UpdateDateTime = DateTime.Now; bool isAddLog = false; if (job.JobStatus == SafeValue.SafeString(ConnectSql.ExecuteScalar("Select JobStatus from JobInfo where JobNo='" + job.JobNo + "'"))) { } else { isAddLog = true; } Manager.ORManager.StartTracking(job, Wilson.ORMapper.InitialState.Updated); Manager.ORManager.PersistChanges(job); if (isAddLog) { EzshipLog.Log(job.JobNo, "", "JO", job.JobStatus); } } Session["SoWhere"] = "JobNo='" + job.JobNo + "'"; this.dsIssue.FilterExpression = Session["SoWhere"].ToString(); if (this.grid_Issue.GetRow(0) != null) { this.grid_Issue.StartEdit(0); } return(job.JobNo); } catch (Exception ex) { throw new Exception(ex.Message + ex.StackTrace); } return(""); }
protected void ASPxGridView1_CustomDataCallback(object sender, ASPxGridViewCustomDataCallbackEventArgs e) { string filter = e.Parameters; ASPxTextBox oidCtr = this.ASPxGridView1.FindEditFormTemplateControl("txt_Oid") as ASPxTextBox; //ASPxTextBox docN = this.ASPxGridView1.FindEditFormTemplateControl("txt_DocNo") as ASPxTextBox; if (filter == "P") { SaveBill(); #region Post string sql = @"SELECT AcYear, AcPeriod, DocType, DocNo, DocDate, DocCurrency, DocExRate, PartyTo, OtherPartyName, DocAmt, LocAmt, AcCode, AcSource, ChqNo, ChqDate, ExportInd, BankName, Remark,GenerateInd FROM pay_doc"; sql += " WHERE Id='" + oidCtr.Text + "'"; DataTable dt = Manager.ORManager.GetDataSet(sql).Tables[0]; 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 otherPartyName = ""; string chqNo = ""; string generateInd = ""; 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(); otherPartyName = dt.Rows[0]["OtherPartyName"].ToString(); chqNo = dt.Rows[0]["ChqNo"].ToString(); generateInd = SafeValue.SafeString(dt.Rows[0]["GenerateInd"]); } else { e.Result = "Can't find the ArReceipt!"; return; } if (generateInd.ToUpper() != "Y") { e.Result = "Have not generate no!"; return; } string sqlDet = string.Format("select count(Id) from pay_line 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 pay_line 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 pay_line 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 pay_line where RepId='{0}' and AcSource='DB'", oidCtr.Text); decimal amt_detDb = SafeValue.SafeDecimal(Manager.ORManager.ExecuteScalar(sql), 0); if (docType == "RE" && locAmt != amt_detCr - amt_detDb) { e.Result = "Amount can't match, can't post"; return; } else if (docType == "PC" && locAmt != -amt_detCr + amt_detDb) { e.Result = "Amount can't match, can't post"; return; } sql = "select count(*) from pay_line 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.OtherPartyName = otherPartyName; 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(pay_line), "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 = 0; det1.CurrencyCrAmt = 0; det1.DbAmt = docAmt; det1.CurrencyDbAmt = locAmt; 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++; pay_line invDet = set[i] as pay_line; 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); EzshipLog.Log(docN, "", docType, "Post"); 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 Id,DocId, DocType FROM pay_line where RepId ='" + oidCtr.Text + "'"; DataTable tab = C2.Manager.ORManager.GetDataSet(sql).Tables[0]; for (int i = 0; i < tab.Rows.Count; i++) { try { string id = tab.Rows[i]["Id"].ToString(); string docId = tab.Rows[i]["DocId"].ToString(); string docType = tab.Rows[i]["DocType"].ToString(); string sql_det = "delete from pay_line where Id='" + id + "'"; if (C2.Manager.ORManager.ExecuteCommand(sql_det) > 0) { UpdateMaster(docId, docType); } } catch (Exception ex) { throw new Exception(ex.Message); } } } catch (Exception ex) { throw new Exception(ex.Message); } #endregion } else if (filter == "Reverse") { #region reverse receipt 0:period is closed? 1:unpost 2:exportind='N' 3: delete all item try { string sql1 = string.Format("select CloseInd from xxaccperiod where Year=(select AcYear from pay_doc where Id='{0}') and Period=(select top(1)AcPeriod from pay_doc where SequenceId='{0}')", oidCtr.Text); if (SafeValue.SafeString(ConnectSql.ExecuteScalar(sql1)) != "N") { throw new Exception("Acc Period is Closed!"); } string sql_invoice = string.Format("select sequenceid from xaglentry where ArApInd='AR' and docno=(select docno from pay_doc where id='{0}') and DocType=(select doctype from pay_doc where id='{0}') ", oidCtr.Text); DeleteGl(SafeValue.SafeInt(ConnectSql.ExecuteScalar(sql_invoice), 0)); sql_invoice = "update pay_doc set IsReturn='true', ExportInd='N' where Id='" + oidCtr.Text + "'"; Manager.ORManager.ExecuteCommand(sql_invoice); string sql = "SELECT Id,DocId, DocType FROM pay_line where RepId ='" + oidCtr.Text + "'"; DataTable tab = C2.Manager.ORManager.GetDataSet(sql).Tables[0]; for (int i = 0; i < tab.Rows.Count; i++) { try { string id = tab.Rows[i]["Id"].ToString(); string docId = tab.Rows[i]["DocId"].ToString(); string docType = tab.Rows[i]["DocType"].ToString(); string sql_det = "delete from pay_line where Id='" + id + "'"; if (C2.Manager.ORManager.ExecuteCommand(sql_det) > 0) { UpdateMaster(docId, docType); } } catch (Exception ex) { throw new Exception(ex.Message); } } } catch (Exception ex) { throw new Exception(ex.Message); } #endregion } else if (filter == "GainLoss") { #region GAIN LOSS ASPxComboBox docType = this.ASPxGridView1.FindEditFormTemplateControl("cbo_DocType") as ASPxComboBox; string sql = string.Format("select (select LocAmt from pay_doc where Id='{0}')-iSNULL(sum(case when AcSource='CR' then -LocAmt else LocAmt end),0) As LocAmt from pay_line where repid='{0}'", oidCtr.Text); if (docType.Text == "RE") { sql = string.Format("select (select LocAmt from pay_doc where Id='{0}')-iSNULL(sum(case when AcSource='DB' then -LocAmt else LocAmt end),0) As LocAmt from pay_line 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"]; pay_line det = new pay_line(); det.AcCode = gainAccCode; if (docType.Text == "RE") { det.AcSource = "CR"; } else { det.AcSource = "DB"; } det.DocType = docType.Text; det.RepType = docType.Text; det.Currency = System.Configuration.ConfigurationManager.AppSettings["Currency"]; det.DocAmt = balAmt; det.DocDate = new DateTime(1900, 1, 1); det.DocId = 0; det.DocNo = ""; 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 pay_line where RepId='" + oidCtr.Text + "'"; int lineNo = SafeValue.SafeInt(Manager.ORManager.ExecuteScalar(sql_detCnt), 0) + 1; det.RepLineNo = lineNo; 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"]; pay_line det = new pay_line(); det.AcCode = gainAccCode; if (docType.Text == "RE") { det.AcSource = "DB"; } else { det.AcSource = "CR"; } det.DocType = docType.Text; det.RepType = docType.Text; det.Currency = System.Configuration.ConfigurationManager.AppSettings["Currency"]; det.DocAmt = -balAmt; det.DocDate = new DateTime(1900, 1, 1); det.DocId = 0; det.DocNo = ""; 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 pay_line where RepId='" + oidCtr.Text + "'"; int lineNo = SafeValue.SafeInt(Manager.ORManager.ExecuteScalar(sql_detCnt), 0) + 1; det.RepLineNo = lineNo; C2.Manager.ORManager.StartTracking(det, Wilson.ORMapper.InitialState.Inserted); C2.Manager.ORManager.PersistChanges(det); } #endregion } else if (filter == "Generate") { string sql = @"SELECT DocType, DocDate FROM pay_doc WHERE Id='" + oidCtr.Text + "'"; DataTable dt = Manager.ORManager.GetDataSet(sql).Tables[0]; if (dt.Rows.Count == 1) { DateTime docDate = SafeValue.SafeDate(dt.Rows[0]["DocDate"], DateTime.Today); string docType = SafeValue.SafeString(dt.Rows[0]["DocType"]); string invN = C2Setup.GetNextNo(docType, "AR-RECEIPT", docDate); sql = string.Format("Update pay_doc set DocNo='{1}',GenerateInd='Y' where Id='{0}'", oidCtr.Text, invN); if (ConnectSql.ExecuteSql(sql) > -1) { C2Setup.SetNextNo(docType, "AR-RECEIPT", invN, docDate); } e.Result = invN; } } }
protected void grid1_CustomDataCallback(object sender, ASPxGridViewCustomDataCallbackEventArgs e) { string s = e.Parameters; if (s == "Save") { C2.JobOrder order = new C2.JobOrder(); ASPxComboBox txt_JobType = ASPxPopupControl1.FindControl("txt_JobType") as ASPxComboBox; ASPxComboBox cbx_jobCate = ASPxPopupControl1.FindControl("cbx_jobCate") as ASPxComboBox; ASPxComboBox txtCustomerId = ASPxPopupControl1.FindControl("cmb_Customer") as ASPxComboBox; ASPxComboBox txtShipperId = ASPxPopupControl1.FindControl("cmb_Carrier") as ASPxComboBox; //ASPxTextBox txtShipperName = ASPxPopupControl1.FindControl("txtShipperName") as ASPxTextBox; ASPxMemo txt_Remark = ASPxPopupControl1.FindControl("txt_Remark") as ASPxMemo; ASPxSpinEdit spin_Weight = ASPxPopupControl1.FindControl("spin_Weight") as ASPxSpinEdit; ASPxSpinEdit spin_Volume = ASPxPopupControl1.FindControl("spin_Volume") as ASPxSpinEdit; ASPxSpinEdit spin_Pkgs = ASPxPopupControl1.FindControl("spin_Pkgs") as ASPxSpinEdit; ASPxComboBox txt_pkgType = ASPxPopupControl1.FindControl("cmb_PackType") as ASPxComboBox; string refType = "SEF"; string runType = "EXPORTREF";//SEF/SEL/SEC/ SCF/SCL/SCC/ SAE/SAC/SLT //if (refType == "SAE") // runType = "AirExport"; //else if (refType == "SAC") // runType = "AirCrossTrade"; //else if (refType == "SCF" || refType == "SCL" || refType == "SCC") // runType = "SeaCrossTrade"; //else if (refType == "SLT") // runType = "LocalTpt"; order.JobNo = C2Setup.GetNextNo(refType, runType, DateTime.Today); order.RefNo = order.JobNo; order.Note1 = txt_JobType.Text; order.Note2 = cbx_jobCate.Text; order.CustomerId = SafeValue.SafeString(txtCustomerId.Value); order.ShipperId = SafeValue.SafeString(txtShipperId.Value); order.ShipperName = txtShipperId.Text; order.Remark = txt_Remark.Text; order.JobDate = DateTime.Today; C2.Manager.ORManager.StartTracking(order, Wilson.ORMapper.InitialState.Inserted); C2.Manager.ORManager.PersistChanges(order); C2Setup.SetNextNo(refType, runType, order.JobNo, DateTime.Today); C2.JobCargo cargo = new C2.JobCargo(); cargo.RefNo = order.JobNo; cargo.Weight = SafeValue.SafeDecimal(spin_Weight.Value, 0); cargo.Volume = SafeValue.SafeDecimal(spin_Volume.Value, 0); cargo.Qty = SafeValue.SafeInt(spin_Pkgs.Value, 0); cargo.PackageType = txt_pkgType.Text; cargo.Remark = ""; C2.Manager.ORManager.StartTracking(cargo, Wilson.ORMapper.InitialState.Inserted); C2.Manager.ORManager.PersistChanges(cargo); EzshipLog.Log(order.JobNo, order.JobNo, "Direct", "Create"); ASPxPopupControl1.ShowOnPageLoad = false; cbx_jobCate.Text = ""; txtCustomerId.Text = ""; txtShipperId.Text = ""; txt_Remark.Text = ""; spin_Weight.Text = ""; spin_Volume.Text = ""; spin_Pkgs.Text = ""; txt_pkgType.Text = ""; e.Result = order.SequenceId + "|" + order.JobNo; //ClientScriptManager cs = Page.ClientScript; //cs.RegisterStartupScript(this.GetType(), "", "<script type=\"text/javascript\">txt_Remark.SetText();cmb_PackType.SetText();spin_Pkgs.SetText();spin_Volume.SetText();spin_Weight.SetText();cmb_Carrier.SetText();cmb_Customer.SetText();cbx_jobCate.SetText();ASPxPopupClientControl.Hide();parent.navTab.openTab(\"" + order.JobNo + "\",\"/Z/job_edit.aspx?id=" + order.SequenceId + "\"" + ",{title:\"" + order.JobNo + "\", fresh:false, external:true});</script>"); } }
protected void ASPxGridView1_CustomDataCallback1(object sender, ASPxGridViewCustomDataCallbackEventArgs e) { string filter = e.Parameters; string[] _filter = filter.Split(','); string p = _filter[0]; string s = _filter[1]; ASPxTextBox docId = this.ASPxGridView1.FindEditFormTemplateControl("txt_Oid") as ASPxTextBox; //get informations from arinvoice if (p.ToUpper() == "P") { SaveBill(); #region Post string sql = @"SELECT AcYear, AcPeriod, AcCode, AcSource, DocType, DocNo, DocDate, DocDueDate, PartyTo, MastType, CurrencyId, ExRate, Term, Description, DocAmt, LocAmt FROM XAArInvoice"; sql += " WHERE SequenceId='" + docId.Text + "'"; DataTable dt = Manager.ORManager.GetDataSet(sql).Tables[0]; 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 = ""; 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(); docAmt = SafeValue.SafeDecimal(dt.Rows[0]["DocAmt"].ToString(), 0); locAmt = SafeValue.SafeDecimal(dt.Rows[0]["LocAmt"].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)); remarks = dt.Rows[0]["Description"].ToString(); partyTo = dt.Rows[0]["PartyTo"].ToString(); } else { e.Result = "Can't find the Ar Invoice!"; return; } string sqlDet = string.Format("select count(SequenceId) from XAArInvoiceDet where DocId='{0}'", docId.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 < 2000 || 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 XAArInvoiceDet where AcSource='CR' and DocId='" + docId.Text + "'"; decimal amt_det = SafeValue.SafeDecimal(C2.Manager.ORManager.ExecuteScalar(sql), 0); sql = "select SUM(LocAmt) from XAArInvoiceDet where AcSource='DB' and DocId='" + docId.Text + "'"; amt_det -= SafeValue.SafeDecimal(C2.Manager.ORManager.ExecuteScalar(sql), 0); if (docAmt != amt_det) { e.Result = "Loc Amount can't match, can't post,Please first resave it,"; return; } sql = "select count(LocAmt) from XAArInvoiceDet where AcCode='' and DocId='" + docId.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.GlNo = GetNo("GLENTRY"); 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.SupplierBillNo = ""; gl.SupplierBillDate = new DateTime(1900, 1, 1); Manager.ORManager.StartTracking(gl, InitialState.Inserted); Manager.ORManager.PersistChanges(gl); glOid = gl.SequenceId; // SetNo(gl.GlNo, "GLENTRY"); //insert Detail OPathQuery query = new OPathQuery(typeof(XAArInvoiceDet), "DocId='" + docId.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 = 0; det1.CurrencyCrAmt = 0; det1.DbAmt = docAmt; det1.CurrencyDbAmt = locAmt; det1.CurrencyId = currency; det1.DocNo = docN; det1.DocType = docType; det1.ExRate = exRate; det1.GlLineNo = index; det1.GlNo = glOid;//gl.GlNo; 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='AR'"), "2033"); for (int i = 0; i < set.Count; i++) { try { index++; XAArInvoiceDet invDet = set[i] as XAArInvoiceDet; XAGlEntryDet det = new XAGlEntryDet(); if (invDet.AcCode == gstAcc) { if (invDet.AcSource == "CR") { gstCrAmt += invDet.LocAmt; } else { gstDbAmt += invDet.LocAmt; } } else { det.AcCode = invDet.AcCode; det.ArApInd = "AR"; det.AcPeriod = acPeriod; det.AcSource = invDet.AcSource; det.AcYear = acYear; if (det.AcSource == "CR") { det.CrAmt = invDet.LocAmt - invDet.GstAmt; det.CurrencyCrAmt = SafeValue.ChinaRound(det.CrAmt * exRate, 2); det.DbAmt = 0; det.CurrencyDbAmt = 0; gstCrAmt += invDet.GstAmt; } else { det.DbAmt = invDet.LocAmt - invDet.GstAmt; det.CurrencyDbAmt = SafeValue.ChinaRound(det.DbAmt * exRate, 2); det.CrAmt = 0; det.CurrencyCrAmt = 0; 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 (gstCrAmt - gstDbAmt != 0) { XAGlEntryDet det = new XAGlEntryDet(); det.AcCode = gstAcc; det.ArApInd = "AR"; det.AcPeriod = acPeriod; det.AcSource = "CR"; det.AcYear = acYear; det.CrAmt = gstCrAmt - gstDbAmt; det.CurrencyCrAmt = gstCrAmt - gstDbAmt; det.DbAmt = 0; det.CurrencyDbAmt = 0; 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(docId.Text); EzshipLog.Log(docN, "", docType, "Post"); e.Result = "Post completely!"; } catch { e.Result = "Posting Error, Please repost!"; DeleteGl(glOid); } #endregion } }
protected void grid_ref_CustomDataCallback(object sender, DevExpress.Web.ASPxGridView.ASPxGridViewCustomDataCallbackEventArgs e) { string s = e.Parameters; ASPxPageControl pageControl = this.grid_ref.FindEditFormTemplateControl("pageControl") as ASPxPageControl; ASPxTextBox refNo = pageControl.FindControl("txt_RefN") as ASPxTextBox; ASPxTextBox masterId = pageControl.FindControl("txtSequenceId") as ASPxTextBox; string userId = HttpContext.Current.User.Identity.Name; if (s == "VoidMaster") { #region void master //billing string sql_cnt = string.Format("select count(SequenceId) from XAArInvoiceDet where MastType='SE' and MastRefNo='{0}'", refNo.Text); int cnt = SafeValue.SafeInt(C2.Manager.ORManager.ExecuteScalar(sql_cnt), 0); if (cnt > 0) { e.Result = "Billing"; return; } ASPxLabel closeIndStr = pageControl.FindControl("lb_JobStatus") as ASPxLabel; string sql = "select statusCode from SeaExportRef where RefNo='" + refNo.Text + "'"; string closeInd = SafeValue.SafeString(C2.Manager.ORManager.ExecuteScalar(sql), "USE");// closeIndStr.Text; if (closeInd == "CNL") { sql = string.Format("update SeaExportRef set statusCode='USE',UpdateBy='{1}',UpdateDateTime='{2}' where RefNo='{0}'", refNo.Text, EzshipHelper.GetUserName(), DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); int res = Manager.ORManager.ExecuteCommand(sql); if (res > 0) { string refType = this.txt_RefType.Text; if (refType.Length > 2) { EzshipLog.Log(refNo.Text, "", refType.Substring(0, 2) == "SE" ? "SE" : "SCT", "Unvoid"); } else { EzshipLog.Log(refNo.Text, "", refType, "Unvoid"); } e.Result = "Success"; } else { e.Result = "Fail"; } } else { string refType = this.txt_RefType.Text; bool closeByEst = EzshipHelper.GetCloseEstInd(refNo.Text, refType); if (closeByEst) { sql = string.Format("update SeaExportRef set statusCode='CNL',UpdateBy='{1}',UpdateDateTime='{2}' where RefNo='{0}'", refNo.Text, EzshipHelper.GetUserName(), DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); int res = Manager.ORManager.ExecuteCommand(sql); if (res > 0) { if (refType.Length > 2) { EzshipLog.Log(refNo.Text, "", refType.Substring(0, 2) == "SE" ? "SE" : "SCT", "Unvoid"); } else { EzshipLog.Log(refNo.Text, "", refType, "Unvoid"); } e.Result = "Success"; } else { e.Result = "Fail"; } } else { e.Result = "NoMatch"; } } #endregion } if (s == "CloseJob") { #region close job ASPxLabel closeIndStr = pageControl.FindControl("lab_CloseInd") as ASPxLabel; ASPxButton btn = pageControl.FindControl("btn_RefCloseJob") as ASPxButton; string sql = string.Format("select statusCode from SeaExportRef where SequenceId='{0}'", masterId.Text); string statusCode = SafeValue.SafeString(C2.Manager.ORManager.ExecuteScalar(sql), "N");// closeIndStr.Text; if (statusCode == "CLS") { sql = string.Format("update SeaExportRef set statusCode='USE',UpdateBy='{1}',UpdateDateTime='{2}' where RefNo='{0}'", refNo.Text, EzshipHelper.GetUserName(), DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); int res = Manager.ORManager.ExecuteCommand(sql); if (res > 0) { string refType = this.txt_RefType.Text; if (refType != null) { EzshipLog.Log(refNo.Text, "", refType.Substring(0, 2) == "SE" ? "SE" : "SCT", "Open"); } e.Result = "Success"; } else { e.Result = "Fail"; } } else { string refType = this.txt_RefType.Text; bool closeByEst = EzshipHelper.GetCloseEstInd(refNo.Text, refType); if (closeByEst) { sql = string.Format("update SeaExportRef set statusCode='CLS',UpdateBy='{1}',UpdateDateTime='{2}' where RefNo='{0}'", refNo.Text, EzshipHelper.GetUserName(), DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); int res = Manager.ORManager.ExecuteCommand(sql); if (res > 0) { if (refType != null) { EzshipLog.Log(refNo.Text, "", refType.Substring(0, 2) == "SE" ? "SE" : "SCT", "Close"); } e.Result = "Success"; } else { e.Result = "Fail"; } } else { e.Result = "NoMatch"; } } #endregion } }
private string InsertInv(string mastType, string soNo, string doNo, string docType) { string sql = string.Format(@"select mast.PartyId,p.termid as Term ,det.ProductCode as Sku,det.LotNo,det.Qty1 as Qty,det.Price,mast.Currency,mast.ExRate,det.Gst ,det.Des1 from wh_transDet det inner join wh_trans mast on mast.DoNO=det.DoNo and mast.DoType=det.DoType left join xxparty p on p.partyid=mast.partyid where mast.DoNO='{0}' ", soNo); if (doNo.Length > 0) { sql = string.Format(@"select mast.PartyId,p.termid as Term ,det.ProductCode as Sku,det.LotNo,det.Qty1 as Qty,tsDet.Price,tsMast.Currency,tsMast.ExRate,tsDet.Gst ,det.Des1 from wh_DoDet det inner join wh_do mast on mast.DoNO=det.DoNo and mast.DoType=det.DoType left join xxparty p on p.partyid=mast.partyid left join wh_transdet tsDet on tsDet.ProductCode=det.ProductCode and tsDet.LotNo=det.LotNo left join wh_trans tsMast on tsMast.doNO=tsDet.DoNo and tsMast.DoType=tsDet.DoType where mast.DoNO='{1}' and tsDet.DoNO='{0}' ", soNo, doNo); } string invN = ""; int invId = 0; DataTable tab = ConnectSql.GetTab(sql); for (int i = 0; i < tab.Rows.Count; i++) { if (i == 0) { string partyId = SafeValue.SafeString(tab.Rows[0]["PartyId"]); string term = SafeValue.SafeString(tab.Rows[0]["Term"]); #region invoice mast string counterType = "AR-IV"; if (docType == "CN") { counterType = "AR-CN"; } C2.XAArInvoice inv = new C2.XAArInvoice(); inv.DocDate = DateTime.Today; invN = C2Setup.GetNextNo("", counterType, inv.DocDate); inv.PartyTo = partyId; inv.DocType = docType; inv.DocNo = invN.ToString(); string[] currentPeriod = EzshipHelper.GetAccPeriod(inv.DocDate); inv.AcYear = SafeValue.SafeInt(currentPeriod[1], inv.DocDate.Year); inv.AcPeriod = SafeValue.SafeInt(currentPeriod[0], inv.DocDate.Month); inv.Term = term; // int dueDay = SafeValue.SafeInt(inv.Term.ToUpper().Replace("DAYS", "").Trim(), 0); inv.DocDueDate = inv.DocDate.AddDays(dueDay);//SafeValue.SafeDate(dueDt.Text, DateTime.Now); inv.Description = ""; inv.CurrencyId = System.Configuration.ConfigurationManager.AppSettings["Currency"]; inv.ExRate = 1; inv.AcCode = EzshipHelper.GetAccArCode(inv.PartyTo, inv.CurrencyId); inv.AcSource = "DB"; inv.SpecialNote = ""; inv.MastType = mastType; inv.MastRefNo = soNo; inv.JobRefNo = doNo; if (doNo.Length > 0) { inv.MastRefNo = doNo; inv.JobRefNo = ""; } 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.InvType = "ACCOUNT"; try { C2.Manager.ORManager.StartTracking(inv, Wilson.ORMapper.InitialState.Inserted); C2.Manager.ORManager.PersistChanges(inv); C2Setup.SetNextNo("", counterType, invN, inv.DocDate); invId = inv.SequenceId; } catch { } #endregion if (invId < 1) { return(""); } } string sku = SafeValue.SafeString(tab.Rows[i]["Sku"]); string des = SafeValue.SafeString(tab.Rows[i]["Des1"]); string lotNo = SafeValue.SafeString(tab.Rows[i]["LotNo"]); int qty = SafeValue.SafeInt(tab.Rows[i]["Qty"], 0); decimal price = SafeValue.SafeDecimal(tab.Rows[i]["Price"], 0); string cur = SafeValue.SafeString(tab.Rows[i]["Currency"]); decimal exRate = SafeValue.SafeDecimal(tab.Rows[i]["ExRate"], 0); decimal gst = SafeValue.SafeDecimal(tab.Rows[i]["Gst"], 0); InsertInv_Det(invId, invN, i + 1, sku, lotNo, des, qty, price, cur, exRate, gst, soNo, doNo, mastType, docType); } if (invId > 0) { if (docType == "IV") { UpdateMaster(invId); } if (docType == "CN") { UpdateCN_Master(invId); } sql = string.Format("update Wh_Trans set DoStatus='Closed',UpdateBy='{1}',UpdateDateTime='{2}' where DoNo='{0}'", soNo, EzshipHelper.GetUserName(), DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); int res = Manager.ORManager.ExecuteCommand(sql); if (res > 0) { EzshipLog.Log(soNo, "", "SO", "Closed"); } } return(invN); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { string sql = ""; string soNo = SafeValue.SafeString(Request.QueryString["RefN"]); string mastType = SafeValue.SafeString(Request.QueryString["JobType"]); string typ = SafeValue.SafeString(Request.QueryString["JobN"]).ToUpper(); string docType = SafeValue.SafeString(Request.QueryString["DocType"]).ToUpper(); if (typ == "SO")//do it by so { sql = string.Format("select count(*) from XaArInvoice where MastRefNo='{0}' and MastType='WH' and DocType='{1}'", soNo, docType); if (SafeValue.SafeInt(ConnectSql.ExecuteScalar(sql), 0) > 0) { Response.Write("Already have invoice, can't generate !"); Response.End(); } if (docType == "IV") { sql = string.Format(@"select count(*) from Wh_TransDet where DoNo='{0}'", soNo); if (SafeValue.SafeInt(ConnectSql.ExecuteScalar(sql), 0) == 0) { Response.Write("NO SKU Line, can't generate !"); Response.End(); } else { string invNo = InsertInv(mastType, soNo, "", docType); EzshipLog.Log(soNo, "", "SO", "Create SO Inv"); Response.Redirect("/opsAccount/ArInvoiceEdit.aspx?no=" + invNo); } } if (docType == "CN") { sql = string.Format(@"select count(*) from Wh_TransDet where DoNo='{0}'", soNo); if (SafeValue.SafeInt(ConnectSql.ExecuteScalar(sql), 0) == 0) { Response.Write("NO SKU Line, can't generate !"); Response.End(); } else { string invNo = InsertInv(mastType, soNo, "", docType); EzshipLog.Log(soNo, "", "SO", "Create CN"); Response.Redirect("/opsAccount/ArCnEdit.aspx?no=" + invNo); } } } else if (typ == "DO")// do it by so { sql = string.Format(@"select count(*) from Wh_TransDet where DoNo='{0}'", soNo); if (SafeValue.SafeInt(ConnectSql.ExecuteScalar(sql), 0) == 0) { Response.Write("NO SKU Line, can't generate !"); Response.End(); } sql = string.Format("select DoNo from wh_do where PoNo='{0}'", soNo); DataTable tab = ConnectSql.GetTab(sql); string invNo = ""; for (int i = 0; i < tab.Rows.Count; i++) { string doNo = tab.Rows[i][0].ToString(); string sql1 = string.Format("select count(*) from XaArInvoice where (MastRefNo='{0}' or JobRefNo='{0}') and MastType='WH'", doNo); if (SafeValue.SafeInt(ConnectSql.ExecuteScalar(sql1), 0) == 0) { invNo = InsertInv(mastType, soNo, doNo, docType); } } if (invNo.Length > 0) { EzshipLog.Log(soNo, "", "DO", "Create DO Inv"); Response.Redirect("/opsAccount/ArInvoiceEdit.aspx?no=" + invNo); } else if (tab.Rows.Count == 0) { Response.Write("Don't have DO !"); Response.End(); } else { Response.Write("DO have the Invoice!"); Response.End(); } } else if (typ == "PO") { sql = string.Format(@"select count(*) from Wh_TransDet where DoNo='{0}'", soNo); if (SafeValue.SafeInt(ConnectSql.ExecuteScalar(sql), 0) == 0) { Response.Write("NO SKU Line, can't generate !"); Response.End(); } sql = string.Format("select count(*) from XAApPayable where (MastRefNo='{0}' or JobRefNo='{0}') and MastType='WH' and DocType='PL'", soNo); if (SafeValue.SafeInt(ConnectSql.ExecuteScalar(sql), 0) > 0) { Response.Write("Already have PO Payable, can't generate !"); Response.End(); } if (docType == "CN") { string invNo = InsertPl(mastType, soNo, "", docType); EzshipLog.Log(soNo, "", "PO", "Create CN"); Response.Redirect("/opsAccount/ArCnEdit.aspx?no=" + invNo); } if (docType == "PL") { string invNo = InsertPl(mastType, soNo, "", "PL"); EzshipLog.Log(soNo, "", "PO", "Create Payable"); Response.Redirect("/opsAccount/ApPayableEdit.aspx?no=" + invNo); } } else if (typ == "DI") { sql = string.Format(@"select count(*) from Wh_TransDet where DoNo='{0}'", soNo); if (SafeValue.SafeInt(ConnectSql.ExecuteScalar(sql), 0) == 0) { Response.Write("NO SKU Line, can't generate !"); Response.End(); } sql = string.Format("select DoNo from wh_do where PoNo='{0}'", soNo); DataTable tab = ConnectSql.GetTab(sql); string invNo = ""; for (int i = 0; i < tab.Rows.Count; i++) { string doNo = tab.Rows[i][0].ToString(); string sql1 = string.Format("select count(*) from XaArInvoice where (MastRefNo='{0}' or JobRefNo='{0}') and MastType='WH'", doNo); if (SafeValue.SafeInt(ConnectSql.ExecuteScalar(sql1), 0) == 0) { invNo = InsertPl(mastType, soNo, doNo, "PL"); } } if (invNo.Length > 0 && docType == "PL") { EzshipLog.Log(soNo, "", "DI", "Create Payable"); Response.Redirect("/opsAccount/ApPayableEdit.aspx?no=" + invNo); } else if (tab.Rows.Count == 0) { Response.Write("Don't have DO !"); Response.End(); } else { Response.Write("DO have the Invoice!"); Response.End(); } } } }
protected void ASPxGridView1_CustomDataCallback(object sender, DevExpress.Web.ASPxGridView.ASPxGridViewCustomDataCallbackEventArgs e) { string doNo = SafeValue.SafeString(Request.QueryString["Sn"].ToString()); string type = SafeValue.SafeString(Request.QueryString["type"].ToString()); string s = e.Parameters; bool action = false; decimal totalQty = 0; decimal value = 0; string product = ""; int result = 0; if (Request.QueryString["Sn"] != null) { #region Vali if (s == "Vali") { for (int i = 0; i < list.Count; i++) { int id = list[i].id; string sku = list[i].sku; string sql = string.Format(@"select count(*) from Wh_DoDet2 d1 inner join Wh_DoDet d on d.ProductCode=d1.Product and d.DoType=d1.DoType and d1.DoNo=d.DoNo where d1.DoNo='{0}' and d1.Product='{1}'", doNo, sku); int cnt = SafeValue.SafeInt(Manager.ORManager.ExecuteScalar(sql), 0); if (cnt > 0) { e.Result = "Fail!Had Picked"; return; } } try { for (int i = 0; i < list.Count; i++) { string sku = list[i].sku; decimal balqty = list[i].avaibleQty; decimal qty = list[i].qty; decimal picking = list[i].pickQty; if (qty <= 0) { e.Result = "No Qty"; return; } if (qty > balqty) { e.Result = "No Balance"; return; } if (balqty < (qty + picking)) { e.Result = "Had Picking,No Enough Stock"; return; } //if(picking==balqty){ // e.Result = "Had Picking,Can't Pick again"; // return; //} } for (int i = 0; i < list.Count; i++) { int id = list[i].id; string sku = list[i].sku; decimal qty = list[i].qty; string lotNo = list[i].lotNo; decimal balqty = list[i].avaibleQty; string loc = list[i].loc; decimal price = list[i].price; decimal pendingpick = list[i].pickQty; string remark = list[i].remark; string palletNo = list[i].palletNo; for (int j = 0; j < list.Count; j++) { string sku1 = list[j].sku; decimal qty1 = list[j].qty; if (sku1 == sku) { totalQty = qty1 + value; } value = qty1; } string sql_sum = string.Format(@"select sum(Qty1) as TotalQty from Wh_DoDet2 where DoNo='{0}' and Product='{1}' and Remark='{2}' and PalletNo='{3}'", doNo, sku, lotNo, remark, palletNo); int total = SafeValue.SafeInt(C2.Manager.ORManager.ExecuteScalar(sql_sum), 0); string sql = string.Format(@"select count(*) from Wh_DoDet2 where DoNo='{0}' and Product='{1}' and LotNo='{2}' and Location='{3}' and Remark='{4}' and PalletNo='{5}'", doNo, sku, lotNo, loc, remark, palletNo); int cnt = SafeValue.SafeInt(C2.Manager.ORManager.ExecuteScalar(sql), 0); string sql_totalQty5 = string.Format(@"select sum(Qty5) as PickQty from Wh_DoDet where DoNo='{0}' and ProductCode='{1}' and Remark='{2}' and PalletNo='{3}'", doNo, sku, remark, palletNo); string sql_totalQty1 = string.Format(@"select sum(Qty1) as PickQty from Wh_DoDet where DoNo='{0}' and ProductCode='{1}' and Remark='{2}' and PalletNo='{3}'", doNo, sku, remark, palletNo); int total_qty5 = SafeValue.SafeInt(C2.Manager.ORManager.ExecuteScalar(sql_totalQty5), 0); int total_qty1 = SafeValue.SafeInt(C2.Manager.ORManager.ExecuteScalar(sql_totalQty1), 0); if (cnt > 0 && (total < total_qty1 || total < total_qty5)) { sql = string.Format(@"update Wh_DoDet2 set Qty1=Qty1+{3} where DoNo='{0}' and Product='{1}' and LotNo='{2}' and Remark='{3}' and PalletNo='{4}'", doNo, sku, lotNo, qty, remark, palletNo); C2.Manager.ORManager.ExecuteCommand(sql); action = false; } else if (cnt > 0 && (total_qty1 == total || total_qty5 == total)) { sql = string.Format(@"delete from Wh_DoDet2 where DoNo='{0}' and Product='{1}' and LotNo='{2}' and Remark='{3}' and PalletNo='{4}'", doNo, sku, lotNo, remark, palletNo); C2.Manager.ORManager.ExecuteCommand(sql); action = true; } else if (cnt == 0) { if ((total_qty1 == total || total_qty5 == total) && totalQty < total) { sql = string.Format(@"delete from Wh_DoDet2 where DoNo='{0}' and Product='{1}' and Qty1={2} and Remark='{3}' and PalletNo='{4}'", doNo, sku, qty, remark, palletNo); C2.Manager.ORManager.ExecuteCommand(sql); } if ((total_qty1 == total || total_qty5 == total) && totalQty >= total) { sql = string.Format(@"delete from Wh_DoDet2 where DoNo='{0}' and Product='{1}' and Remark='{2}' and PalletNo='{3}'", doNo, sku, remark, palletNo); C2.Manager.ORManager.ExecuteCommand(sql); } action = true; } if (action) { TransferToDo(id, doNo, sku, lotNo, qty, loc, price); } sql = string.Format(@"select JobStatus from Wh_DoDet where Id={0}", id); string jobstatus = SafeValue.SafeString(ConnectSql.ExecuteScalar(sql)); if (jobstatus == "Pending") { sql = string.Format(@"update Wh_DoDet set Qty1=Qty5,Qty5=0,JobStatus='Picked' where Id={0}", id); result = SafeValue.SafeInt(ConnectSql.ExecuteSql(sql), 0); } } EzshipLog.Log(doNo, "", "OUT", "Picked"); e.Result = "Success"; } catch { } } #endregion #region OK if (s == "OK") { try { for (int i = 0; i < list.Count; i++) { string sku = list[i].sku; decimal balqty = list[i].avaibleQty; decimal qty = list[i].qty; decimal picking = list[i].pickQty; if (qty <= 0) { e.Result = "No Qty"; return; } if (qty > balqty) { e.Result = "No Balance"; return; } if (balqty < (qty + picking)) { e.Result = "Had Picking,No Enough Stock"; return; } //if (picking >balqty) //{ // e.Result = "Had Picking,Can't Pick again"; // return; //} } for (int i = 0; i < list.Count; i++) { int id = list[i].id; string sku = list[i].sku; decimal qty = list[i].qty; string lotNo = list[i].lotNo; decimal balqty = list[i].avaibleQty; string loc = list[i].loc; decimal price = list[i].price; string remark = list[i].remark; string palletNo = list[i].palletNo; for (int j = 0; j < list.Count; j++) { string sku1 = list[j].sku; decimal qty1 = list[j].qty; if (sku1 == sku) { totalQty = qty1 + value; } value = qty1; } string sql_sum = string.Format(@"select sum(Qty1) as TotalQty from Wh_DoDet2 where DoNo='{0}' and Product='{1}' and Remark='{2}' and PalletNo='{3}'", doNo, sku, remark, palletNo); int total = SafeValue.SafeInt(C2.Manager.ORManager.ExecuteScalar(sql_sum), 0); string sql = string.Format(@"select count(*) from Wh_DoDet2 where DoNo='{0}' and Product='{1}' and LotNo='{2}' and Location='{3}' and Remark='{4}' and PalletNo='{5}'", doNo, sku, lotNo, loc, remark, palletNo); int cnt = SafeValue.SafeInt(C2.Manager.ORManager.ExecuteScalar(sql), 0); string sql_totalQty5 = string.Format(@"select sum(Qty5) as PickQty from Wh_DoDet where DoNo='{0}' and ProductCode='{1}' and Remark='{2}' and PalletNo='{3}'", doNo, sku, remark, palletNo); string sql_totalQty1 = string.Format(@"select sum(Qty1) as PickQty from Wh_DoDet where DoNo='{0}' and ProductCode='{1}' and Remark='{2}' and PalletNo='{3}'", doNo, sku, remark, palletNo); int total_qty5 = SafeValue.SafeInt(C2.Manager.ORManager.ExecuteScalar(sql_totalQty5), 0); int total_qty1 = SafeValue.SafeInt(C2.Manager.ORManager.ExecuteScalar(sql_totalQty1), 0); if (cnt > 0 && (total < total_qty1 || total < total_qty5)) { sql = string.Format(@"update Wh_DoDet2 set Qty1=Qty1+{3} where DoNo='{0}' and Product='{1}' and LotNo='{2}' and Remark='{3}' and PalletNo='{4}'", doNo, sku, lotNo, qty, remark, palletNo); C2.Manager.ORManager.ExecuteCommand(sql); action = false; } else if (cnt > 0 && (total_qty1 == total || total_qty5 == total)) { sql = string.Format(@"delete from Wh_DoDet2 where DoNo='{0}' and Product='{1}' and Remark='{2}' and PalletNo='{3}'", doNo, sku, remark, palletNo); C2.Manager.ORManager.ExecuteCommand(sql); action = true; } else if (cnt == 0) { if ((total_qty1 == total || total_qty5 == total) && totalQty < total) { sql = string.Format(@"select count(*) from Wh_DoDet2 where DoNo='{0}' and Product='{1}' and Qty1={2} and Remark='{3}' and PalletNo='{4}'", doNo, sku, qty, remark, palletNo); cnt = SafeValue.SafeInt(C2.Manager.ORManager.ExecuteScalar(sql), 0); if (cnt > 0) { sql = string.Format(@"delete from Wh_DoDet2 where DoNo='{0}' and Product='{1}' and Qty1={2} and Remark='{3}' and PalletNo='{4}'", doNo, sku, qty, remark, palletNo); C2.Manager.ORManager.ExecuteCommand(sql); } } if ((total_qty1 == total || total_qty5 == total) && totalQty >= total) { sql = string.Format(@"delete from Wh_DoDet2 where DoNo='{0}' and Product='{1}' and Remark='{2}' and PalletNo='{3}'", doNo, sku, remark, palletNo); C2.Manager.ORManager.ExecuteCommand(sql); } action = true; } if (action) { TransferToDo(id, doNo, sku, lotNo, qty, loc, price); } sql = string.Format(@"select JobStatus from Wh_DoDet where Id={0}", id); string jobstatus = SafeValue.SafeString(ConnectSql.ExecuteScalar(sql)); if (jobstatus == "Pending") { sql = string.Format(@"update Wh_DoDet set Qty1=Qty5+Qty1,JobStatus='Picked' where Id={0}", id); result = SafeValue.SafeInt(ConnectSql.ExecuteSql(sql), 0); sql = string.Format(@"update Wh_DoDet set Qty5=0,JobStatus='Picked' where Id={0}", id); result = SafeValue.SafeInt(ConnectSql.ExecuteSql(sql), 0); } product = sku; } e.Result = "Success"; EzshipLog.Log(doNo, "", "OUT", "Picked"); } catch { } } #endregion } else { e.Result = "Please keyin select party "; } }
protected void grid_Transport_CustomDataCallback(object sender, ASPxGridViewCustomDataCallbackEventArgs e) { string s = e.Parameters; ASPxPageControl pageControl = this.grid_Transport.FindEditFormTemplateControl("pageControl") as ASPxPageControl; ASPxTextBox masterId = pageControl.FindControl("txt_Id") as ASPxTextBox; ASPxTextBox jobNo = pageControl.FindControl("txt_JobNo") as ASPxTextBox; string userId = HttpContext.Current.User.Identity.Name; if (s == "VoidJob") { #region void master //billing string sql_cnt = string.Format("select count(SequenceId) from XAArInvoiceDet where MastType='TPT' and MastRefNo='{0}'", jobNo.Text); int cnt = SafeValue.SafeInt(C2.Manager.ORManager.ExecuteScalar(sql_cnt), 0); if (cnt > 0) { e.Result = "Billing"; return; } ASPxLabel closeIndStr = pageControl.FindControl("lb_JobStatus") as ASPxLabel; string sql = "select StatusCode from TPT_Job where JobNo='" + jobNo.Text + "'"; string closeInd = SafeValue.SafeString(C2.Manager.ORManager.ExecuteScalar(sql), "N");// closeIndStr.Text; if (closeInd == "CNL") { sql = string.Format("update TPT_Job set StatusCode='USE',UpdateBy='{1}',UpdateDateTime='{2}' where JobNo='{0}'", jobNo.Text, EzshipHelper.GetUserName(), DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); int res = Manager.ORManager.ExecuteCommand(sql); if (res > 0) { EzshipLog.Log(jobNo.Text, "", "TPT", "Unvoid"); e.Result = "Success"; } else { e.Result = "Fail"; } } else { bool closeByEst = EzshipHelper.GetCloseEstInd(jobNo.Text, "TPT"); if (closeByEst) { sql = string.Format("update TPT_Job set StatusCode='CNL',UpdateBy='{1}',UpdateDateTime='{2}' where JobNo='{0}'", jobNo.Text, EzshipHelper.GetUserName(), DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); int res = Manager.ORManager.ExecuteCommand(sql); if (res > 0) { EzshipLog.Log(jobNo.Text, "", "TPT", "Void"); e.Result = "Success"; } else { e.Result = "Fail"; } } else { e.Result = "NoMatch"; } } #endregion } if (s == "CloseJob") { #region close job ASPxLabel closeIndStr = pageControl.FindControl("lab_CloseInd") as ASPxLabel; ASPxButton btn = pageControl.FindControl("btn_CloseJob") as ASPxButton; string sql = "select StatusCode from Tpt_Job where id='" + masterId.Text + "'"; string closeInd = SafeValue.SafeString(C2.Manager.ORManager.ExecuteScalar(sql), "USE");// closeIndStr.Text; if (closeInd == "CLS") { sql = string.Format("update Tpt_Job set StatusCode='USE' where Id='{0}'", masterId.Text); int res = Manager.ORManager.ExecuteCommand(sql); if (res > 0) { EzshipLog.Log(jobNo.Text, "", "TPT", "Open"); e.Result = "Success"; //btn.Text = "Close Job"; //closeIndStr.Text = "N"; } else { e.Result = "Fail"; } } else { sql = string.Format("update Tpt_Job set StatusCode='CLS' where Id='{2}'", DateTime.Today.ToString("yyyy-MM-dd"), userId, masterId.Text); int res = Manager.ORManager.ExecuteCommand(sql); if (res > 0) { EzshipLog.Log(jobNo.Text, "", "TPT", "Close"); e.Result = "Success"; //btn.Text = "Open Job"; //closeIndStr.Text = "Y"; } else { e.Result = "Fail"; } } #endregion } if (s == "Save") { e.Result = SaveJob(); } }
protected void grid_Export_CustomDataCallback(object sender, DevExpress.Web.ASPxGridView.ASPxGridViewCustomDataCallbackEventArgs e) { string s = e.Parameters; ASPxTextBox txtHouseNo = this.grid_Export.FindEditFormTemplateControl("txtHouseNo") as ASPxTextBox; ASPxTextBox txtRefNo = this.grid_Export.FindEditFormTemplateControl("txtRefNo") as ASPxTextBox; int oid = SafeValue.SafeInt(this.grid_Export.GetRowValues(this.grid_Export.EditingRowVisibleIndex, new string[] { "Id" }), 0); string sql = "select StatusCode from air_job where Id=" + oid + ""; string jobStatus = SafeValue.SafeString(Manager.ORManager.ExecuteScalar(sql)); if (s == "VoidHouse") { #region VoidHouse string sql_cnt = string.Format("select count(SequenceId) from XAArInvoiceDet where MastType='AE' and MastRefNo='{0}' and JobRefNo='{1}' ", txtRefNo.Text, txtHouseNo.Text); int cnt = SafeValue.SafeInt(C2.Manager.ORManager.ExecuteScalar(sql_cnt), 0); if (cnt > 0) { e.Result = "Billing"; return; } if (jobStatus == "CNL") { sql = string.Format("update air_job set StatusCode='USE' where Id={0}", oid); int res = Manager.ORManager.ExecuteCommand(sql); if (res > 0) { UpdateMast(txtRefNo.Text); EzshipLog.Log(txtRefNo.Text, txtHouseNo.Text, "AE", "Unvoid"); e.Result = "Success"; //btn.Text = "Close Job"; //closeIndStr.Text = "C"; } else { e.Result = "Fail"; } } else { string refType = "AE"; bool closeByEst = EzshipHelper.GetCloseEstInd(txtHouseNo.Text, refType); if (closeByEst) { sql = string.Format("update air_job set StatusCode='CNL' where Id={0}", oid); int res = Manager.ORManager.ExecuteCommand(sql); if (res > 0) { UpdateMast(txtRefNo.Text); EzshipLog.Log(txtRefNo.Text, txtHouseNo.Text, "AE", "Void"); e.Result = "Success"; //btn.Text = "Close Job"; //closeIndStr.Text = "C"; } else { e.Result = "Fail"; } } else { e.Result = "NoMatch"; } } #endregion } }
private string SavePo() { try { ASPxPageControl pageControl = this.grd_Do.FindEditFormTemplateControl("pageControl") as ASPxPageControl; ASPxDateEdit txt_Date = this.grd_Do.FindEditFormTemplateControl("txt_Date") as ASPxDateEdit; ASPxTextBox txt_Id = grd_Do.FindEditFormTemplateControl("txt_Id") as ASPxTextBox; string pId = SafeValue.SafeString(txt_Id.Text, ""); Wilson.ORMapper.OPathQuery query = new Wilson.ORMapper.OPathQuery(typeof(WhTrans), "Id='" + pId + "'"); WhTrans whTrans = C2.Manager.ORManager.GetObject(query) as WhTrans; bool action = false; string poNo = ""; if (whTrans == null) { action = true; whTrans = new WhTrans(); poNo = C2Setup.GetNextNo("", "BlanketPO", txt_Date.Date); } ASPxComboBox cmb_Status = this.grd_Do.FindEditFormTemplateControl("cmb_Status") as ASPxComboBox; whTrans.DoStatus = SafeValue.SafeString(cmb_Status.Value); ASPxButtonEdit txt_PartyId = grd_Do.FindEditFormTemplateControl("txt_PartyId") as ASPxButtonEdit; whTrans.PartyId = SafeValue.SafeString(txt_PartyId.Text); whTrans.DoDate = SafeValue.SafeDate(txt_Date.Date, DateTime.Today); ASPxDateEdit txt_ExpectedDate = this.grd_Do.FindEditFormTemplateControl("txt_ExpectedDate") as ASPxDateEdit; whTrans.ExpectedDate = txt_ExpectedDate.Date; ASPxTextBox txt_PartyName = grd_Do.FindEditFormTemplateControl("txt_PartyName") as ASPxTextBox; whTrans.PartyName = txt_PartyName.Text; ASPxMemo txt_PartyAdd = grd_Do.FindEditFormTemplateControl("txt_PartyAdd") as ASPxMemo; whTrans.PartyAdd = txt_PartyAdd.Text; //ASPxTextBox txt_PostalCode = grd_Do.FindEditFormTemplateControl("txt_PostalCode") as ASPxTextBox; //whTrans.PartyPostalcode = txt_PostalCode.Text; //ASPxButtonEdit txt_PartyCity = grd_Do.FindEditFormTemplateControl("txt_PartyCity") as ASPxButtonEdit; //whTrans.PartyCity = txt_PartyCity.Text; //ASPxButtonEdit txt_PartyCountry = grd_Do.FindEditFormTemplateControl("txt_PartyCountry") as ASPxButtonEdit; //whTrans.PartyCountry = txt_PartyCountry.Text; ASPxMemo txt_Remark1 = grd_Do.FindEditFormTemplateControl("txt_Remark1") as ASPxMemo; whTrans.Remark1 = txt_Remark1.Text; ASPxMemo txt_Remark2 = grd_Do.FindEditFormTemplateControl("txt_Remark2") as ASPxMemo; whTrans.Remark2 = txt_Remark2.Text; ASPxMemo txt_CollectFrom = grd_Do.FindEditFormTemplateControl("txt_CollectFrom") as ASPxMemo; whTrans.CollectFrom = txt_CollectFrom.Text; ASPxMemo txt_DeliveryTo = grd_Do.FindEditFormTemplateControl("txt_DeliveryTo") as ASPxMemo; whTrans.DeliveryTo = txt_DeliveryTo.Text; ASPxButtonEdit txt_WareHouseId = grd_Do.FindEditFormTemplateControl("txt_WareHouseId") as ASPxButtonEdit; whTrans.WareHouseId = txt_WareHouseId.Text; ASPxTextBox pic = grd_Do.FindEditFormTemplateControl("txt_Pic") as ASPxTextBox; whTrans.Pic = pic.Text; ASPxButtonEdit currency = grd_Do.FindEditFormTemplateControl("txt_Currency") as ASPxButtonEdit; whTrans.Currency = currency.Text; ASPxSpinEdit exRate = grd_Do.FindEditFormTemplateControl("spin_ExRate") as ASPxSpinEdit; whTrans.ExRate = SafeValue.SafeDecimal(exRate.Value, 1); ASPxComboBox payTerm = grd_Do.FindEditFormTemplateControl("cmb_PayTerm") as ASPxComboBox; whTrans.PayTerm = payTerm.Text; ASPxComboBox incoTerm = grd_Do.FindEditFormTemplateControl("cmb_IncoTerm") as ASPxComboBox; whTrans.IncoTerm = incoTerm.Text; ASPxTextBox txt_MasterDocNo = grd_Do.FindEditFormTemplateControl("txt_MasterDocNo") as ASPxTextBox; whTrans.MasterDocNo = txt_MasterDocNo.Text; ASPxComboBox cmb_OrderType = grd_Do.FindEditFormTemplateControl("cmb_OrderType") as ASPxComboBox; whTrans.OrderType = cmb_OrderType.Text; //shipment info ASPxTextBox txt_Vessel = pageControl.FindControl("txt_Vessel") as ASPxTextBox; whTrans.Vessel = txt_Vessel.Text; ASPxTextBox txt_Voyage = pageControl.FindControl("txt_Voyage") as ASPxTextBox; whTrans.Voyage = txt_Voyage.Text; ASPxDateEdit date_Etd = pageControl.FindControl("date_Etd") as ASPxDateEdit; whTrans.Etd = date_Etd.Date; ASPxButtonEdit txt_Pol = pageControl.FindControl("txt_Pol") as ASPxButtonEdit; whTrans.Pol = txt_Pol.Text; ASPxButtonEdit txt_Pod = pageControl.FindControl("txt_Pod") as ASPxButtonEdit; whTrans.Pod = txt_Pod.Text; ASPxDateEdit date_Eta = pageControl.FindControl("date_Eta") as ASPxDateEdit; whTrans.Eta = date_Eta.Date; ASPxTextBox txt_OceanBl = pageControl.FindControl("txt_OceanBl") as ASPxTextBox; whTrans.Obl = txt_OceanBl.Text; ASPxTextBox txt_HouseBl = pageControl.FindControl("txt_HouseBl") as ASPxTextBox; whTrans.Hbl = txt_HouseBl.Text; ASPxDateEdit date_EtaDest = pageControl.FindControl("date_EtaDest") as ASPxDateEdit; whTrans.EtaDest = date_EtaDest.Date; ASPxTextBox txt_VehicleNo = pageControl.FindControl("txt_VehicleNo") as ASPxTextBox; whTrans.Vehicle = txt_VehicleNo.Text; ASPxTextBox txt_COO = pageControl.FindControl("txt_COO") as ASPxTextBox; whTrans.Coo = txt_COO.Text; ASPxButtonEdit txt_Carrier = pageControl.FindControl("txt_Carrier") as ASPxButtonEdit; whTrans.Carrier = txt_Carrier.Text; //party ASPxButtonEdit txt_AgentId = pageControl.FindControl("txt_AgentId") as ASPxButtonEdit; whTrans.AgentId = txt_AgentId.Text; ASPxTextBox txt_AgentName = pageControl.FindControl("txt_AgentName") as ASPxTextBox; whTrans.AgentName = txt_AgentName.Text; ASPxTextBox txt_AgentZip = pageControl.FindControl("txt_AgentZip") as ASPxTextBox; whTrans.AgentZip = txt_AgentZip.Text; ASPxMemo txt_AgentAdd = pageControl.FindControl("txt_AgentAdd") as ASPxMemo; whTrans.AgentAdd = txt_AgentAdd.Text; ASPxTextBox txt_AgentTel = pageControl.FindControl("txt_AgentTel") as ASPxTextBox; whTrans.AgentTel = txt_AgentTel.Text; ASPxTextBox txt_AgentContact = pageControl.FindControl("txt_AgentContact") as ASPxTextBox; whTrans.AgentContact = txt_AgentContact.Text; ASPxButtonEdit txt_AgentCountry = pageControl.FindControl("txt_AgentCountry") as ASPxButtonEdit; whTrans.AgentCountry = txt_AgentCountry.Text; ASPxButtonEdit txt_AgentCity = pageControl.FindControl("txt_AgentCity") as ASPxButtonEdit; whTrans.AgentCity = txt_AgentCity.Text; ASPxButtonEdit txt_NotifyId = pageControl.FindControl("txt_NotifyId") as ASPxButtonEdit; whTrans.NotifyId = txt_NotifyId.Text; ASPxTextBox txt_NotifyName = pageControl.FindControl("txt_NotifyName") as ASPxTextBox; whTrans.NotifyName = txt_NotifyName.Text; ASPxTextBox txt_NotifyZip = pageControl.FindControl("txt_NotifyZip") as ASPxTextBox; whTrans.NotifyZip = txt_NotifyZip.Text; ASPxMemo txt_NotifyAdd = pageControl.FindControl("txt_NotifyAdd") as ASPxMemo; whTrans.NotifyAdd = txt_NotifyAdd.Text; ASPxTextBox txt_NotifyTel = pageControl.FindControl("txt_NotifyTel") as ASPxTextBox; whTrans.NotifyTel = txt_NotifyTel.Text; ASPxTextBox txt_NotifyContact = pageControl.FindControl("txt_NotifyContact") as ASPxTextBox; whTrans.NotifyContact = txt_NotifyContact.Text; ASPxButtonEdit txt_NotifyCountry = pageControl.FindControl("txt_NotifyCountry") as ASPxButtonEdit; whTrans.NotifyCountry = txt_NotifyCountry.Text; ASPxButtonEdit txt_NotifyCity = pageControl.FindControl("txt_NotifyCity") as ASPxButtonEdit; whTrans.NotifyCity = txt_NotifyCity.Text; ASPxButtonEdit txt_ConsigneeId = pageControl.FindControl("txt_ConsigneeId") as ASPxButtonEdit; whTrans.ConsigneeId = txt_ConsigneeId.Text; ASPxTextBox txt_ConsigneeName = pageControl.FindControl("txt_ConsigneeName") as ASPxTextBox; whTrans.ConsigneeName = txt_ConsigneeName.Text; ASPxTextBox txt_ConsigneeZip = pageControl.FindControl("txt_ConsigneeZip") as ASPxTextBox; whTrans.ConsigneeZip = txt_ConsigneeZip.Text; ASPxMemo txt_ConsigneeAdd = pageControl.FindControl("txt_ConsigneeAdd") as ASPxMemo; whTrans.ConsigneeAdd = txt_ConsigneeAdd.Text; ASPxTextBox txt_ConsigneeTel = pageControl.FindControl("txt_ConsigneeTel") as ASPxTextBox; whTrans.ConsigneeTel = txt_ConsigneeTel.Text; ASPxTextBox txt_ConsigneeContact = pageControl.FindControl("txt_ConsigneeContact") as ASPxTextBox; whTrans.ConsigneeContact = txt_ConsigneeContact.Text; ASPxButtonEdit txt_ConsigneeCountry = pageControl.FindControl("txt_ConsigneeCountry") as ASPxButtonEdit; whTrans.ConsigneeCountry = txt_ConsigneeCountry.Text; ASPxButtonEdit txt_ConsigneeCity = pageControl.FindControl("txt_ConsigneeCity") as ASPxButtonEdit; whTrans.ConsigneeCity = txt_ConsigneeCity.Text; ASPxButtonEdit btn_Lc = grd_Do.FindEditFormTemplateControl("btn_Lc") as ASPxButtonEdit; whTrans.LcNo = btn_Lc.Text; if (action) { whTrans.DoNo = poNo; whTrans.DoType = "BP"; whTrans.CreateBy = EzshipHelper.GetUserName(); whTrans.CreateDateTime = DateTime.Now; Manager.ORManager.StartTracking(whTrans, Wilson.ORMapper.InitialState.Inserted); Manager.ORManager.PersistChanges(whTrans); C2Setup.SetNextNo("", "BlanketPO", poNo, txt_Date.Date); } else { whTrans.UpdateBy = EzshipHelper.GetUserName(); whTrans.UpdateDateTime = DateTime.Now; bool isAddLog = false; if (whTrans.DoStatus == SafeValue.SafeString(ConnectSql.ExecuteScalar("Select DoStatus from wh_trans where DoNo='" + whTrans.DoNo + "'"))) { } else { isAddLog = true; } Manager.ORManager.StartTracking(whTrans, Wilson.ORMapper.InitialState.Updated); Manager.ORManager.PersistChanges(whTrans); if (isAddLog) { EzshipLog.Log(whTrans.DoNo, "", "PO", whTrans.DoStatus); } } Session["BPWhere"] = "DoNo='" + whTrans.DoNo + "'"; this.dsDo.FilterExpression = Session["BPWhere"].ToString(); if (this.grd_Do.GetRow(0) != null) { this.grd_Do.StartEdit(0); } return(whTrans.DoNo); } catch { } return(""); }
protected string SaveJob() { try { ASPxPageControl pageControl = this.grid_Issue.FindEditFormTemplateControl("pageControl_Hbl") as ASPxPageControl; ASPxTextBox DoNo = grid_Issue.FindEditFormTemplateControl("txt_JobNo") as ASPxTextBox; ASPxTextBox txt_Id = grid_Issue.FindEditFormTemplateControl("txt_Id") as ASPxTextBox; string pId = SafeValue.SafeString(txt_Id.Text, ""); Wilson.ORMapper.OPathQuery query = new Wilson.ORMapper.OPathQuery(typeof(JobSchedule), "Id='" + pId + "'"); JobSchedule job = C2.Manager.ORManager.GetObject(query) as JobSchedule; ASPxDateEdit issueDate = grid_Issue.FindEditFormTemplateControl("date_IssueDate") as ASPxDateEdit; bool isNew = false; //const string runType = "DOOUT"; string issueN = ""; if (job == null) { job = new JobSchedule(); isNew = true; issueN = C2Setup.GetNextNo("", "JobOrder", issueDate.Date); job.JobDate = issueDate.Date; } ASPxDateEdit doDate = grid_Issue.FindEditFormTemplateControl("date_IssueDate") as ASPxDateEdit; if (doDate != null) { job.JobDate = doDate.Date; } ASPxComboBox cmb_Status = grid_Issue.FindEditFormTemplateControl("cmb_Status") as ASPxComboBox; if (cmb_Status != null) { job.JobStage = SafeValue.SafeString(cmb_Status.Value); } ASPxComboBox cmb_JobType = grid_Issue.FindEditFormTemplateControl("cmb_JobType") as ASPxComboBox; if (cmb_JobType != null) { job.JobType = SafeValue.SafeString(cmb_JobType.Value); } //Main Info ASPxButtonEdit txt_CustomerId = grid_Issue.FindEditFormTemplateControl("txt_CustomerId") as ASPxButtonEdit; if (txt_CustomerId != null) { job.CustomerId = txt_CustomerId.Text; } ASPxTextBox txt_CustomerName = grid_Issue.FindEditFormTemplateControl("txt_CustomerName") as ASPxTextBox; if (txt_CustomerName != null) { job.CustomerName = txt_CustomerName.Text; } ASPxMemo memo_Address = grid_Issue.FindEditFormTemplateControl("memo_Address") as ASPxMemo; if (memo_Address != null) { job.CustomerAdd = memo_Address.Text; } ASPxTextBox txt_PostalCode = grid_Issue.FindEditFormTemplateControl("txt_PostalCode") as ASPxTextBox; if (txt_PostalCode != null) { job.Postalcode = txt_PostalCode.Text; } ASPxTextBox txt_Contact = grid_Issue.FindEditFormTemplateControl("txt_Contact") as ASPxTextBox; if (txt_Contact != null) { job.Contact = txt_Contact.Text; } ASPxTextBox txt_Tel = grid_Issue.FindEditFormTemplateControl("txt_Tel") as ASPxTextBox; if (txt_Tel != null) { job.Tel = txt_Tel.Text; } ASPxTextBox txt_Email = grid_Issue.FindEditFormTemplateControl("txt_Email") as ASPxTextBox; if (txt_Email != null) { job.Email = txt_Email.Text; } ASPxTextBox txt_Fax = grid_Issue.FindEditFormTemplateControl("txt_Fax") as ASPxTextBox; if (txt_Fax != null) { job.Fax = txt_Fax.Text; } ASPxMemo remark = grid_Issue.FindEditFormTemplateControl("txt_Remark") as ASPxMemo; if (remark != null) { job.Remark = remark.Text; } ASPxButtonEdit currency = grid_Issue.FindEditFormTemplateControl("txt_Currency") as ASPxButtonEdit; if (currency != null) { job.Currency = currency.Text; } ASPxSpinEdit exRate = grid_Issue.FindEditFormTemplateControl("spin_ExRate") as ASPxSpinEdit; if (exRate != null) { job.ExRate = SafeValue.SafeDecimal(exRate.Value, 1); } ASPxComboBox payTerm = grid_Issue.FindEditFormTemplateControl("cmb_PayTerm") as ASPxComboBox; if (payTerm != null) { job.PayTerm = payTerm.Text; } ASPxDateEdit date_ExpiryDate = grid_Issue.FindEditFormTemplateControl("date_ExpiryDate") as ASPxDateEdit; if (date_ExpiryDate != null) { job.ExpiryDate = date_ExpiryDate.Date; } ASPxMemo txt_PackRemark = grid_Issue.FindEditFormTemplateControl("txt_PackRemark") as ASPxMemo; if (txt_PackRemark != null) { job.PackRmk = txt_PackRemark.Text; } ASPxMemo txt_MoveRemark = grid_Issue.FindEditFormTemplateControl("txt_MoveRemark") as ASPxMemo; if (txt_MoveRemark != null) { job.MoveRmk = txt_MoveRemark.Text; } ASPxButtonEdit txt_WareHouseId = grid_Issue.FindEditFormTemplateControl("txt_WareHouseId") as ASPxButtonEdit; if (txt_WareHouseId != null) { job.WareHouseId = txt_WareHouseId.Text; } ASPxButtonEdit btn_OriginPort = grid_Issue.FindEditFormTemplateControl("btn_OriginPort") as ASPxButtonEdit; if (btn_OriginPort != null) { job.OriginPort = btn_OriginPort.Text; } ASPxButtonEdit btn_DestinationPort = grid_Issue.FindEditFormTemplateControl("btn_DestinationPort") as ASPxButtonEdit; if (btn_DestinationPort != null) { job.DestinationPort = btn_DestinationPort.Text; } ASPxMemo memo_Address1 = grid_Issue.FindEditFormTemplateControl("memo_Address1") as ASPxMemo; if (memo_Address1 != null) { job.OriginAdd = memo_Address1.Text; } ASPxMemo memo_Address2 = grid_Issue.FindEditFormTemplateControl("memo_Address2") as ASPxMemo; if (memo_Address2 != null) { job.DestinationAdd = memo_Address2.Text; } ASPxSpinEdit spin_Volumne = grid_Issue.FindEditFormTemplateControl("spin_Volumne") as ASPxSpinEdit; if (spin_Volumne != null) { job.Volumne = SafeValue.SafeDecimal(spin_Volumne.Value); } ASPxMemo memo_Description = grid_Issue.FindEditFormTemplateControl("memo_Description") as ASPxMemo; if (memo_Description != null) { job.ItemDes = memo_Description.Text; } ASPxTextBox memo_Volumn = grid_Issue.FindEditFormTemplateControl("memo_Volumn") as ASPxTextBox; if (memo_Volumn != null) { job.VolumneRmk = memo_Description.Text; } ASPxSpinEdit spin_HeadCount = grid_Issue.FindEditFormTemplateControl("spin_HeadCount") as ASPxSpinEdit; if (spin_HeadCount != null) { job.HeadCount = SafeValue.SafeInt(spin_HeadCount.Value, 0); } ASPxDateEdit date_Pack = grid_Issue.FindEditFormTemplateControl("date_Pack") as ASPxDateEdit; if (date_Pack != null) { job.PackDate = date_Pack.Date; } ASPxComboBox cmb_Via = grid_Issue.FindEditFormTemplateControl("cmb_Via") as ASPxComboBox; if (cmb_Via != null) { job.ViaWh = cmb_Via.Text; } ASPxDateEdit date_StorageStartDate = grid_Issue.FindEditFormTemplateControl("date_StorageStartDate") as ASPxDateEdit; if (date_StorageStartDate != null) { job.StorageStartDate = date_StorageStartDate.Date; } ASPxSpinEdit spin_StorageFreeDays = grid_Issue.FindEditFormTemplateControl("spin_StorageFreeDays") as ASPxSpinEdit; if (spin_StorageFreeDays != null) { job.StorageFreeDays = SafeValue.SafeInt(spin_StorageFreeDays.Value, 0); } ASPxSpinEdit spin_STotalDays = grid_Issue.FindEditFormTemplateControl("spin_STotalDays") as ASPxSpinEdit; if (spin_STotalDays != null) { job.StorageTotalDays = Helper.Safe.SafeInt(spin_STotalDays.Value); } ASPxTextBox txt_TripNo = grid_Issue.FindEditFormTemplateControl("txt_TripNo") as ASPxTextBox; if (txt_TripNo != null) { job.TripNo = txt_TripNo.Text; } ASPxDateEdit date_MoveDate = grid_Issue.FindEditFormTemplateControl("date_MoveDate") as ASPxDateEdit; if (date_MoveDate != null) { job.MoveDate = date_MoveDate.Date; } ASPxSpinEdit spin_Charges = grid_Issue.FindEditFormTemplateControl("spin_Charges") as ASPxSpinEdit; if (spin_Charges != null) { job.Charges = SafeValue.SafeDecimal(spin_Charges.Value); } ASPxButtonEdit btn_PortOfEntry = grid_Issue.FindEditFormTemplateControl("btn_PortOfEntry") as ASPxButtonEdit; if (btn_PortOfEntry != null) { job.EntryPort = btn_PortOfEntry.Text; } ASPxComboBox txt_Mode = grid_Issue.FindEditFormTemplateControl("cmb_Mode") as ASPxComboBox; if (txt_Mode != null) { job.Mode = txt_Mode.Text; } ASPxDateEdit date_Eta = grid_Issue.FindEditFormTemplateControl("date_Eta") as ASPxDateEdit; if (date_Eta != null) { job.Eta = date_Eta.Date; } ASPxTextBox txt_TruckNo = grid_Issue.FindEditFormTemplateControl("txt_TruckNo") as ASPxTextBox; if (txt_TruckNo != null) { job.TruckNo = txt_TruckNo.Text; } ASPxButtonEdit btn_OriginCity = grid_Issue.FindEditFormTemplateControl("btn_OriginCity") as ASPxButtonEdit; if (btn_OriginCity != null) { job.OriginCity = btn_OriginCity.Text; } ASPxButtonEdit btn_DestCity = grid_Issue.FindEditFormTemplateControl("btn_DestCity") as ASPxButtonEdit; if (btn_DestCity != null) { job.DestCity = btn_DestCity.Text; } ASPxTextBox txt_OriginPostal = grid_Issue.FindEditFormTemplateControl("txt_OriginPostal") as ASPxTextBox; if (txt_OriginPostal != null) { job.OriginPostal = txt_OriginPostal.Text; } ASPxTextBox txt_DestPostal = grid_Issue.FindEditFormTemplateControl("txt_DestPostal") as ASPxTextBox; if (txt_DestPostal != null) { job.DestPostal = txt_DestPostal.Text; } ASPxComboBox cmb_ServiceType = grid_Issue.FindEditFormTemplateControl("cmb_ServiceType") as ASPxComboBox; if (cmb_ServiceType != null) { job.ServiceType = cmb_ServiceType.Text; } //Additional //ASPxComboBox cmb_FullPacking = pageControl.FindControl("cmb_FullPacking") as ASPxComboBox; //if (cmb_FullPacking != null) // job.Item1 = SafeValue.SafeString(cmb_FullPacking.Value); //ASPxComboBox cmb_UnFull = pageControl.FindControl("cmb_UnFull") as ASPxComboBox; //if (cmb_UnFull != null) // job.Item2 = SafeValue.SafeString(cmb_UnFull.Value); //ASPxTextBox txt_Details = pageControl.FindControl("txt_Details") as ASPxTextBox; //if (txt_Details != null) // job.ItemDetail1 = txt_Details.Text; //ASPxTextBox txt_UnpackDetails = pageControl.FindControl("txt_UnpackDetails") as ASPxTextBox; //if (txt_UnpackDetails != null) // job.ItemDetail2 = txt_UnpackDetails.Text; //ASPxComboBox cmb_Insurance = pageControl.FindControl("cmb_Insurance") as ASPxComboBox; //if (cmb_Insurance != null) // job.Item3 = SafeValue.SafeString(cmb_Insurance.Value); //ASPxTextBox txt_Percentage = pageControl.FindControl("txt_Percentage") as ASPxTextBox; //if (txt_Percentage != null) // job.ItemValue3 = txt_Percentage.Text; //ASPxTextBox txt_Value = pageControl.FindControl("txt_Value") as ASPxTextBox; //if (txt_Value != null) // job.ItemData3 = txt_Value.Text; //ASPxSpinEdit txt_Premium = pageControl.FindControl("txt_Premium") as ASPxSpinEdit; //if (txt_Premium != null) // job.ItemPrice3 = SafeValue.SafeDecimal(txt_Premium.Text); //ASPxComboBox cmb_PianoApply = pageControl.FindControl("cmb_PianoApply") as ASPxComboBox; //if (cmb_PianoApply != null) // job.Item4 = SafeValue.SafeString(cmb_PianoApply.Value); //ASPxTextBox txt_PainoDetails = pageControl.FindControl("txt_PainoDetails") as ASPxTextBox; //if (txt_PainoDetails != null) // job.ItemDetail4 = txt_PainoDetails.Text; //ASPxSpinEdit spin_Charges1 = pageControl.FindControl("spin_Charges1") as ASPxSpinEdit; //if (spin_Charges1 != null) // job.ItemPrice4 = SafeValue.SafeDecimal(spin_Charges1.Value); //ASPxComboBox cmb_Safe = pageControl.FindControl("cmb_Safe") as ASPxComboBox; //if (cmb_Safe != null) // job.Item5 = cmb_Safe.Text; //ASPxTextBox txt_Brand = pageControl.FindControl("txt_Brand") as ASPxTextBox; //if (txt_Brand != null) // job.ItemValue5 = SafeValue.SafeString(txt_Brand.Value); //ASPxSpinEdit spin_Weight = pageControl.FindControl("spin_Weight") as ASPxSpinEdit; //if (spin_Weight != null) // job.ItemPrice5 = SafeValue.SafeDecimal(spin_Weight.Value); //ASPxComboBox cmb_Crating = pageControl.FindControl("cmb_Crating") as ASPxComboBox; //if (cmb_Crating != null) // job.Item6 = SafeValue.SafeString(cmb_Crating.Value); //ASPxTextBox txt_Details1 = pageControl.FindControl("txt_Details1") as ASPxTextBox; //if (txt_Details1 != null) // job.ItemDetail6 = txt_Details1.Text; //ASPxSpinEdit spin_Charges2 = pageControl.FindControl("spin_Charges2") as ASPxSpinEdit; //if (spin_Charges2 != null) // job.ItemPrice6 = SafeValue.SafeDecimal(spin_Charges2.Value); //ASPxComboBox cmb_Handyman = pageControl.FindControl("cmb_Handyman") as ASPxComboBox; //if (cmb_Handyman != null) // job.Item7 = SafeValue.SafeString(cmb_Handyman.Value); //ASPxComboBox cmb_Complimentory = pageControl.FindControl("cmb_Complimentory") as ASPxComboBox; //if (cmb_Complimentory != null) // job.ItemValue7 = SafeValue.SafeString(cmb_Complimentory.Value); //ASPxTextBox txt_Details2 = pageControl.FindControl("txt_Details2") as ASPxTextBox; //if (txt_Details2 != null) // job.ItemDetail7 = txt_Details2.Text; //ASPxSpinEdit spin_Charges3 = pageControl.FindControl("spin_Charges3") as ASPxSpinEdit; //if (spin_Charges3 != null) // job.ItemPrice7 = SafeValue.SafeDecimal(spin_Charges3.Value); //ASPxComboBox cmb_Maid = pageControl.FindControl("cmb_Maid") as ASPxComboBox; //if (cmb_Maid != null) // job.Item8 = SafeValue.SafeString(cmb_Maid.Value); //ASPxComboBox cmb_Complimentory1 = pageControl.FindControl("cmb_Complimentory1") as ASPxComboBox; //if (cmb_Complimentory1 != null) // job.ItemValue8 = SafeValue.SafeString(cmb_Complimentory1.Value); //ASPxTextBox txt_Details3 = pageControl.FindControl("txt_Details3") as ASPxTextBox; //if (txt_Details3 != null) // job.ItemDetail8 = txt_Details3.Text; //ASPxSpinEdit spin_Charges4 = pageControl.FindControl("spin_Charges4") as ASPxSpinEdit; //if (spin_Charges4 != null) // job.ItemPrice8 = SafeValue.SafeDecimal(spin_Charges4.Value); //ASPxComboBox cmb_Shifting = pageControl.FindControl("cmb_Shifting") as ASPxComboBox; //if (cmb_Shifting != null) // job.Item9 = SafeValue.SafeString(cmb_Shifting.Value); //ASPxComboBox cmb_Complimentory2 = pageControl.FindControl("cmb_Complimentory2") as ASPxComboBox; //if (cmb_Complimentory2 != null) // job.ItemValue9 = SafeValue.SafeString(cmb_Complimentory2.Value); //ASPxTextBox txt_Details4 = pageControl.FindControl("txt_Details4") as ASPxTextBox; //if (txt_Details4 != null) // job.ItemDetail9 = txt_Details4.Text; //ASPxSpinEdit spin_Charges5 = pageControl.FindControl("spin_Charges5") as ASPxSpinEdit; //if (spin_Charges5 != null) // job.ItemPrice9 = SafeValue.SafeDecimal(spin_Charges5.Value); //ASPxComboBox cmb_Disposal = pageControl.FindControl("cmb_Disposal") as ASPxComboBox; //if (cmb_Disposal != null) // job.Item10 = cmb_Disposal.Text; //ASPxComboBox cmb_Complimentory3 = pageControl.FindControl("cmb_Complimentory3") as ASPxComboBox; //if (cmb_Complimentory3 != null) // job.ItemValue10 = cmb_Complimentory3.Text; //ASPxTextBox txt_Details5 = pageControl.FindControl("txt_Details5") as ASPxTextBox; //if (txt_Details5 != null) // job.ItemDetail10 = txt_Details5.Text; //ASPxSpinEdit spin_Charges6 = pageControl.FindControl("spin_Charges6") as ASPxSpinEdit; //if (spin_Charges6 != null) // job.ItemPrice10 = SafeValue.SafeDecimal(spin_Charges6.Value); //ASPxComboBox cmb_PickUp = pageControl.FindControl("cmb_PickUp") as ASPxComboBox; //if (cmb_PickUp != null) // job.Item11 = SafeValue.SafeString(cmb_PickUp.Value); //ASPxTextBox txt_Details6 = pageControl.FindControl("txt_Details6") as ASPxTextBox; //if (txt_Details6 != null) // job.ItemDetail11 = txt_Details6.Text; //ASPxComboBox cmb_Additional = pageControl.FindControl("cmb_Additional") as ASPxComboBox; //if (cmb_Additional != null) // job.Item12 = cmb_Additional.Text; //ASPxTextBox txt_Details7 = pageControl.FindControl("txt_Details7") as ASPxTextBox; //if (txt_Details7 != null) // job.ItemDetail12 = txt_Details7.Text; //ASPxComboBox cmb_BadAccess = pageControl.FindControl("cmb_BadAccess") as ASPxComboBox; //if (cmb_BadAccess != null) // job.Item13 = SafeValue.SafeString(cmb_BadAccess.Value); //ASPxComboBox cmb_Origin = pageControl.FindControl("cmb_Origin") as ASPxComboBox; //if (cmb_Origin != null) // job.ItemValue13 = cmb_Origin.Text; //ASPxComboBox cmb_Destination = pageControl.FindControl("cmb_Destination") as ASPxComboBox; //if (cmb_Destination != null) // job.ItemData13 = SafeValue.SafeString(cmb_Destination.Value); //ASPxComboBox cmb_Storage = pageControl.FindControl("cmb_Storage") as ASPxComboBox; //if (cmb_Storage != null) // job.Item14 = SafeValue.SafeString(cmb_Storage.Value); //ASPxComboBox cmb_Complimentory4 = pageControl.FindControl("cmb_Complimentory4") as ASPxComboBox; //if (cmb_Complimentory4 != null) // job.ItemValue14 = SafeValue.SafeString(cmb_Complimentory4.Value); //ASPxTextBox txt_Details8 = pageControl.FindControl("txt_Details8") as ASPxTextBox; //if (txt_Details8 != null) // job.ItemDetail14 = txt_Details8.Text; //ASPxSpinEdit spin_Charges7 = pageControl.FindControl("spin_Charges7") as ASPxSpinEdit; //if (spin_Charges7 != null) // job.ItemPrice14 = SafeValue.SafeDecimal(spin_Charges7.Value); //ASPxTextBox txt_How = pageControl.FindControl("txt_How") as ASPxTextBox; //if (txt_How != null) // job.Answer1 = txt_How.Text; //ASPxTextBox txt_Other = pageControl.FindControl("txt_Other") as ASPxTextBox; //if (txt_Other != null) // job.Answer2 = txt_Other.Text; //ASPxTextBox txt_Move = pageControl.FindControl("txt_Move") as ASPxTextBox; //if (txt_Move != null) // job.Answer3 = txt_Move.Text; //ASPxTextBox txt_UnsuccessRemark = pageControl.FindControl("txt_UnsuccessRemark") as ASPxTextBox; //if (txt_UnsuccessRemark != null) // job.Answer4 = txt_UnsuccessRemark.Text; //ASPxComboBox cmb_WorkStatus = grid_Issue.FindEditFormTemplateControl("cmb_WorkStatus") as ASPxComboBox; //if (cmb_WorkStatus != null) // job.WorkStatus = SafeValue.SafeString(cmb_WorkStatus.Value); //Quotation //ASPxHtmlEditor txt_Attention1 = pageControl.FindControl("txt_Attention1") as ASPxHtmlEditor; //if (txt_Attention1 != null) // job.Attention1 = txt_Attention1.Html; //ASPxHtmlEditor txt_Attention2 = pageControl.FindControl("txt_Attention2") as ASPxHtmlEditor; //if (txt_Attention2 != null) // job.Attention2 = txt_Attention2.Html; //ASPxHtmlEditor txt_Attention3 = pageControl.FindControl("txt_Attention3") as ASPxHtmlEditor; //if (txt_Attention3 != null) // job.Attention3 = txt_Attention3.Html; //ASPxHtmlEditor txt_Attention4 = pageControl.FindControl("txt_Attention4") as ASPxHtmlEditor; //if (txt_Attention4 != null) // job.Attention4 = txt_Attention4.Html; //ASPxHtmlEditor txt_Attention5 = pageControl.FindControl("txt_Attention5") as ASPxHtmlEditor; //if (txt_Attention5 != null) // job.Attention5 = txt_Attention5.Html; //if (cmb_Status.Text == "Job Confirmation") //{ // job.WorkStatus = "Pending"; //} //ASPxComboBox cmb_SalesId = grid_Issue.FindEditFormTemplateControl("cmb_SalesId") as ASPxComboBox; //if (cmb_SalesId != null) // job.Value4 = cmb_SalesId.Text; //if (cmb_Status.Text == "Job Confirmation") //{ // job.WorkStatus = "Pending"; //} //if (job.JobStage == "Customer Inquiry") //{ // job.DateTime1 = DateTime.Now; //} //if (job.WorkStatus == "Costing") //{ // job.DateTime3 = DateTime.Now; //} //if (job.WorkStatus == "Quotation") //{ // job.DateTime4 = DateTime.Now; //} //if (job.WorkStatus == "Job Confirmation") //{ // job.DateTime5 = DateTime.Now; //} //if (job.WorkStatus == "Billing") //{ // job.DateTime6 = DateTime.Now; //} //if (job.WorkStatus == "Job Completion") //{ // job.DateTime7 = DateTime.Now; //} //if (job.WorkStatus == "Job Close") //{ // job.DateTime8 = DateTime.Now; //} //ASPxDateEdit date_DateTime2 = grid_Issue.FindEditFormTemplateControl("date_DateTime2") as ASPxDateEdit; //if (date_DateTime2 != null) //{ // if (!date_DateTime2.Date.IsDaylightSavingTime()) // job.DateTime2 = date_DateTime2.Date; // else // job.DateTime2 = DateTime.Now; //} //ASPxMemo memo_Notes = pageControl.FindControl("memo_Notes") as ASPxMemo; //if (memo_Notes != null) // job.Notes = memo_Notes.Text; string userId = HttpContext.Current.User.Identity.Name; if (isNew) { job.CreateBy = userId; job.CreateDateTime = DateTime.Now; job.UpdateBy = userId; job.UpdateDateTime = DateTime.Now; job.JobNo = issueN; Manager.ORManager.StartTracking(job, Wilson.ORMapper.InitialState.Inserted); Manager.ORManager.PersistChanges(job); C2Setup.SetNextNo("", "JobOrder", issueN, issueDate.Date); } else { job.UpdateBy = userId; job.UpdateDateTime = DateTime.Now; bool isAddLog = false; if (job.JobStatus == SafeValue.SafeString(ConnectSql.ExecuteScalar("Select JobStatus from JobSchedule where JobNo='" + job.JobNo + "'"))) { } else { isAddLog = true; } Manager.ORManager.StartTracking(job, Wilson.ORMapper.InitialState.Updated); Manager.ORManager.PersistChanges(job); if (isAddLog) { EzshipLog.Log(job.JobNo, "", "JO", job.JobStatus); } } Session["SoWhere"] = "JobNo='" + job.JobNo + "'"; this.dsSchedule.FilterExpression = Session["SoWhere"].ToString(); if (this.grid_Issue.GetRow(0) != null) { this.grid_Issue.StartEdit(0); } return(job.JobNo); } catch (Exception ex) { throw new Exception(ex.Message + ex.StackTrace); } return(""); }
protected string SaveJob() { try { ASPxTextBox txt_Id = grid_Issue.FindEditFormTemplateControl("txt_Id") as ASPxTextBox; string pId = SafeValue.SafeString(txt_Id.Text, ""); Wilson.ORMapper.OPathQuery query = new Wilson.ORMapper.OPathQuery(typeof(JobInfo), "Id='" + pId + "'"); JobInfo job = C2.Manager.ORManager.GetObject(query) as JobInfo; ASPxDateEdit issueDate = grid_Issue.FindEditFormTemplateControl("date_IssueDate") as ASPxDateEdit; bool isNew = false; //const string runType = "DOOUT"; string issueN = ""; if (job == null) { job = new JobInfo(); isNew = true; issueN = C2Setup.GetNextNo("", "JobOrder", issueDate.Date); job.JobDate = issueDate.Date; } ASPxDateEdit doDate = grid_Issue.FindEditFormTemplateControl("date_IssueDate") as ASPxDateEdit; job.JobDate = doDate.Date; job.JobStage = "Customer Inquir"; ASPxComboBox cmb_JobType = grid_Issue.FindEditFormTemplateControl("cmb_JobType") as ASPxComboBox; job.JobType = SafeValue.SafeString(cmb_JobType.Value); //Main Info ASPxButtonEdit txt_CustomerId = grid_Issue.FindEditFormTemplateControl("txt_CustomerId") as ASPxButtonEdit; job.CustomerId = txt_CustomerId.Text; ASPxTextBox txt_CustomerName = grid_Issue.FindEditFormTemplateControl("txt_CustomerName") as ASPxTextBox; job.CustomerName = txt_CustomerName.Text; ASPxMemo memo_Address = grid_Issue.FindEditFormTemplateControl("memo_Address") as ASPxMemo; job.CustomerAdd = memo_Address.Text; ASPxTextBox txt_PostalCode = grid_Issue.FindEditFormTemplateControl("txt_PostalCode") as ASPxTextBox; job.Postalcode = txt_PostalCode.Text; ASPxTextBox txt_Contact = grid_Issue.FindEditFormTemplateControl("txt_Contact") as ASPxTextBox; job.Contact = txt_Contact.Text; ASPxTextBox txt_Tel = grid_Issue.FindEditFormTemplateControl("txt_Tel") as ASPxTextBox; job.Tel = txt_Tel.Text; ASPxTextBox txt_Email = grid_Issue.FindEditFormTemplateControl("txt_Email") as ASPxTextBox; job.Email = txt_Email.Text; ASPxTextBox txt_Fax = grid_Issue.FindEditFormTemplateControl("txt_Fax") as ASPxTextBox; job.Fax = txt_Fax.Text; ASPxMemo remark = grid_Issue.FindEditFormTemplateControl("txt_Remark") as ASPxMemo; job.Remark = remark.Text; job.WorkStatus = "PENDING"; string userId = HttpContext.Current.User.Identity.Name; if (isNew) { job.CreateBy = userId; job.CreateDateTime = DateTime.Now; job.UpdateBy = userId; job.UpdateDateTime = DateTime.Now; job.JobNo = issueN; Manager.ORManager.StartTracking(job, Wilson.ORMapper.InitialState.Inserted); Manager.ORManager.PersistChanges(job); C2Setup.SetNextNo("", "JobOrder", issueN, issueDate.Date); } else { job.UpdateBy = userId; job.UpdateDateTime = DateTime.Now; bool isAddLog = false; if (job.JobStatus == SafeValue.SafeString(ConnectSql.ExecuteScalar("Select JobStatus from JobInfo where DoNo='" + job.JobNo + "'"))) { } else { isAddLog = true; } Manager.ORManager.StartTracking(job, Wilson.ORMapper.InitialState.Updated); Manager.ORManager.PersistChanges(job); if (isAddLog) { EzshipLog.Log(job.JobNo, "", "JO", job.JobStatus); } } return(job.JobNo); } catch { } return(""); }