public StoreInPlan(SessionInfo _session = null, StoreInPlanHeadModel model = null) { InitializeComponent(); this._repo = new StoreInPlanRepo(); this._repoIn = new StoreInRepo(); this._repoCurr = new CurrenciesRepo(); this._repoSupplier = new SupplierRepo(); this._repoBT = new BussinessTypeRepo(); this._repoMaker = new MakerRepo(); this._repoMill = new MillRepo(); this._repoCmdt = new Commodity(); this._repoSpec = new SpecRepo(); this._repoCoating = new CoatingRepo(); this._repoWhse = new WharehouseRepo(); this._repoPort = new ImportPortRepo(); this._repoCust = new CustomerRepo(); this._repoLookup = new LookupRepo(); this.SourceStr = ""; //Initial Session and content this.HeadContent = new StoreInPlanHeadModel(); epiSession = _session; if (model == null) { this.IMEXReviewFlag = false; } else { this.HeadContent = model; this.IMEXReviewFlag = true; } this.ModelClone = new StoreInPlanHeadModel(); this.POTrans = new POLineModel(); }
public StoreInPlanDialog(SessionInfo _session, IList<StoreInPlanDialogModel> param = null)//, int Status = 2, string TransType = "") { InitializeComponent(); this._repo = new StoreInPlanRepo(); this.HeadContent = new StoreInPlanDialogModel(); this.list = param; epiSession = _session; //this.status = Status; //this.Type = TransType; }
private void dgvList_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { HeadContent = _repo.GetByID(dgvList.Rows[e.RowIndex].Cells[1].Value.ToString()); this.Close(); }
public StoreInPlanHeadModel SaveHead(StoreInPlanHeadModel model, SessionInfo _session) { ///TODO : not yet fix GETDATE() string sql = ""; if (model.InsertState) { model.StoreInPlanId = GenerateId(); model.StoreInPlanNum = model.StoreInPlanId.ToString("000000"); } if (model.ImportFlag != 0) { model.ImexConfirm = "1"; } sql += string.Format(@"IF NOT EXISTS ( SELECT * FROM ucc_ic_StoreInPlanHead (NOLOCK) WHERE StoreInPlanNum = N'{3}' ) BEGIN INSERT INTO ucc_ic_StoreInPlanHead (Company ,Plant ,StoreInPlanId ,StoreInPlanNum ,TransactionType ,BType ,SupplierCode ,IMexItemNo ,InvoiceNum ,InvoiceDate ,PORate ,DutyRate ,TisiFlag ,LoadPort ,ArivePort ,ETDDate ,ETADate ,Vessel ,IMEXChecked ,MillCode ,MakerCode ,StoreInFlag ,CreationDate ,LastUpdateDate ,CreatedBy ,UpdatedBy ,CurrencyCode ,ImexConfirm ,UserGroup ,CustID, OpenOrder) VALUES (N'{0}' --<Company, nvarchar(8),> , N'{1}' --<Plant, nvarchar(8),> , {2} --<StoreInPlanId, int,> , N'{3}' --<StoreInPlanNum, nvarchar(10),> , N'{4}' --<TransactionType, nvarchar(15),> , N'{5}' --<BType, nchar(10),> , N'{6}' --<SupplierCode, nvarchar(50),> , N'{7}' --<IMexItemNo, nvarchar(30),> , N'{8}' --<InvoiceNum, nvarchar(15),> , GETDATE() --<InvoiceDate, datetime,> , {9} --<PORate, int,> , {10} --<DutyRate, int,> , {11} --<TisiFlag, tinyint,> , N'{12}' --<LoadPort, nvarchar(30),> , N'{13}' --<ArivePort, nvarchar(30),> , GETDATE() --<ETDDate, datetime,> , GETDATE() --<ETADate, datetime,> , N'{14}' --<Vessel, nvarchar(30),> , {15} --<IMEXChecked, int,> , N'{16}' --<MillCode, nvarchar(50),> , N'{17}' --<MakerCode, nvarchar(50),> , {18} --<StoreInFlag, tinyint,> , GETDATE() --<CreationDate, datetime,> , GETDATE() --<LastUpdateDate, datetime,> , N'{19}' --<CreatedBy, varchar(45),> , N'{19}' --<UpdatedBy, varchar(45),> , N'{20}' --<CurrencyCode, nchar(10),> , N'{15}' --<IMEXChecked, nchar(10),> , N'{22}' --<IMEXChecked, nchar(10),> , N'{23}' --CustID , {24} --OpenOrder ) END ELSE BEGIN UPDATE ucc_ic_StoreInPlanHead SET Company = N'{0}' --<Company, nvarchar(8),> ,Plant = N'{1}' --<Plant, nvarchar(8),> ,StoreInPlanId = {2} --<StoreInPlanId, int,> ,StoreInPlanNum = N'{3}' --<StoreInPlanNum, nvarchar(10),> ,TransactionType = N'{4}' --<TransactionType, nvarchar(15),> ,BType = N'{5}' --<BType, nchar(10),> ,SupplierCode = N'{6}' --<SupplierCode, nvarchar(50),> ,IMexItemNo = N'{7}' --<IMexItemNo, nvarchar(30),> ,InvoiceNum = N'{8}' --<InvoiceNum, nvarchar(15),> ,InvoiceDate = GETDATE() --<InvoiceDate, datetime,> ,PORate = {9} --<PORate, int,> ,DutyRate = {10} --<DutyRate, int,> ,TisiFlag = {11} --<TisiFlag, tinyint,> ,LoadPort = N'{12}' --<LoadPort, nvarchar(30),> ,ArivePort = N'{13}' --<ArivePort, nvarchar(30),> ,ETDDate = GETDATE() --<ETDDate, datetime,> ,ETADate = GETDATE() --<ETADate, datetime,> ,Vessel = N'{14}' --<Vessel, nvarchar(30),> ,IMEXChecked = {15} --<IMEXChecked, int,> ,MillCode = N'{16}' --<MillCode, nvarchar(50),> ,MakerCode = N'{17}' --<MakerCode, nvarchar(50),> ,StoreInFlag = {18} --<StoreInFlag, tinyint,> ,CreationDate = GETDATE() --<CreationDate, datetime,> ,LastUpdateDate = GETDATE() --<LastUpdateDate, datetime,> ,CreatedBy = N'{19}' --<CreatedBy, varchar(45),> ,UpdatedBy = N'{19}' --<UpdatedBy, varchar(45),> ,CurrencyCode = N'{20}' --<CurrencyCode, nchar(10),> ,ImexConfirm = N'{15}' --<IMEXChecked, int,> ,ImexRemark = N'{21}' ,UserGroup = N'{22}' ,CustID = N'{23}' ,OpenOrder = {24} WHERE StoreInPlanNum = N'{3}' END" + Environment.NewLine , _session.CompanyID , _session.PlantID , model.StoreInPlanId , model.StoreInPlanNum , model.ImportFlag , model.BussinessType , model.SupplierCode , model.IMexItemNo , model.InvoiceNum , model.ExchangeRate , 0 , Convert.ToInt32(string.IsNullOrEmpty(model.TisiFlag) ? "0" : model.TisiFlag) , model.LoadPort , model.ArivePort , model.Vessel , model.ImexConfirm , model.MillCode , model.MakerCode , 0 , _session.UserID , model.CurrencyCode , model.ImexRemark , model.UserGroup , model.CustID , model.OpenOrder); Repository.Instance.ExecuteWithTransaction(sql, "Store In Plan Header"); return GetByID(model.StoreInPlanNum); }
public bool GetPOLine(string PONumber, string SaleContract, StoreInPlanHeadModel model, int POLine, out string msg) { bool result = false; string sql = string.Format(@"SELECT pod.* FROM PODetail pod INNER JOIN POHeader poh ON(pod.PONUM = poh.PONum) WHERE poh.ShortChar10 = N'{0}' AND poh.ShortChar02 = N'{1}' AND pod.POLine = {2} AND poh.ShortChar03 = N'{3}' and poh.ShortChar04 = N'{4}'" , PONumber, SaleContract, POLine, model.MakerCode, model.MillCode); msg = Repository.Instance.GetOne<string>(sql, "ShortChar10"); if (msg != null) { result = true; } return result; }
public bool GetPOBySaleContract(string Plant, string SaleContract, StoreInPlanHeadModel model, out string msg) { bool result = false; string sql = string.Format(@"SELECT * FROM POHeader WHERE ShortChar02 = N'{0}' and ShortChar03 = N'{1}' and ShortChar04 = N'{2}' and Approve = 1" , SaleContract, model.MakerCode, model.MillCode); msg = Repository.Instance.GetOne<string>(sql, "ShortChar10"); if (msg != null) { result = true; } return result; }
public bool GetPOByPONumber(string Plant, string PONumber, StoreInPlanHeadModel model, out string msg, out int PONum) { bool result = false; string sql = string.Format(@"SELECT * FROM POHeader WHERE PONum = N'{0}' and ShortChar03 = N'{1}' and ShortChar04 = N'{2}' and Approve = 1" , PONumber, model.MakerCode, model.MillCode); msg = Repository.Instance.GetOne<string>(sql, "ShortChar02"); PONum = Repository.Instance.GetOne<int>(sql, "PONUM"); if (msg != null) { result = true; } return result; }
public ImexConfirmCheckList(SessionInfo _session = null, StoreInPlanHeadModel model = null) { InitializeComponent(); this._repo = new StoreInPlanRepo(); epiSession = _session; }
private void SetHeaderContent(StoreInPlanHeadModel model) { ClearHeaderContent(); txtStoreInPlanNum.DataBindings.Add(new Binding("Text", model, "StoreInPlanNum", false)); txtInvoiceNum.DataBindings.Add("Text", model, "InvoiceNum", false, DataSourceUpdateMode.OnPropertyChanged); txtSupplierCode.DataBindings.Add("Text", model, "SupplierCode", false, DataSourceUpdateMode.OnPropertyChanged); txtSupplierName.DataBindings.Add("Text", model, "SupplierName", false, DataSourceUpdateMode.OnPropertyChanged); txtCustID.DataBindings.Add("Text", model, "CustID", false, DataSourceUpdateMode.OnPropertyChanged); txtCustomerName.DataBindings.Add("Text", model, "CustomerName", false, DataSourceUpdateMode.OnPropertyChanged); txtMakerCode.DataBindings.Add("Text", model, "MakerCode", false, DataSourceUpdateMode.OnPropertyChanged); txtMakerName.DataBindings.Add("Text", model, "MakerName", false, DataSourceUpdateMode.OnPropertyChanged); txtMillCode.DataBindings.Add("Text", model, "MillCode", false, DataSourceUpdateMode.OnPropertyChanged); txtMillName.DataBindings.Add("Text", model, "MillName", false, DataSourceUpdateMode.OnPropertyChanged); txtBussinessType.DataBindings.Add("Text", model, "BussinessType", false, DataSourceUpdateMode.OnPropertyChanged); txtBussinessTypeName.DataBindings.Add("Text", model, "BussinessTypeName", false, DataSourceUpdateMode.OnPropertyChanged); txtVessel.DataBindings.Add("Text", model, "Vessel", false, DataSourceUpdateMode.OnPropertyChanged); txtExchangeRate.DataBindings.Add("Text", model, "ExchangeRate", true, DataSourceUpdateMode.OnPropertyChanged, 1, "#,##0.000000"); txtIMEXRemark.DataBindings.Add("Text", model, "ImexRemark", false, DataSourceUpdateMode.OnPropertyChanged); txtOrderType.DataBindings.Add("Text", model, "OrderType", false, DataSourceUpdateMode.OnPropertyChanged); dtpETADate.Value = model.ETADate; dtpETDDate.Value = model.ETDDate; dtpInvoiceDate.Value = model.InvoiceDate; cmdCurrencyCode.DataSource = model.Currencies; cmdCurrencyCode.DisplayMember = "CurrencyCode"; cmdCurrencyCode.DataBindings.Add("Text", model, "ExchangeRate"); cmbLoadPort.DataSource = model.ImportPorts; cmbLoadPort.DisplayMember = "PortCode"; cmbLoadPort.DataBindings.Add("Text", model, "LoadPort", false, DataSourceUpdateMode.OnPropertyChanged); cmbArivePort.DataSource = model.ArivePorts; cmbArivePort.DisplayMember = "PortCode"; cmbArivePort.DataBindings.Add("Text", model, "ArivePort", false, DataSourceUpdateMode.OnPropertyChanged); #region Handling tab control. ((Control)this.tabControl1.TabPages[0]).Enabled = true; ((Control)this.tabControl1.TabPages[1]).Enabled = true; if (model.ImportFlag == 0) { //Active the first tab. tabControl1.SelectedIndex = 0; //Set label tab to 'Import'. tabControl1.TabPages[0].Text = "Import"; //Disable 'Action' menu. actionToolStripMenuItem.Visible = false; //Disable the second tab. ((Control)this.tabControl1.TabPages[1]).Enabled = false; } else if (model.ImportFlag == 1) { //Active the first tab. tabControl1.SelectedIndex = 0; //Set label tab to 'Domestic'. tabControl1.TabPages[0].Text = "Domestic"; //Enable 'Action' menu. actionToolStripMenuItem.Visible = true; //Disable the second tab. ((Control)this.tabControl1.TabPages[1]).Enabled = false; } else { //Active the first tab. tabControl1.SelectedIndex = 1; //Disable 'Action' menu. actionToolStripMenuItem.Visible = false; //Disable the first tab. ((Control)this.tabControl1.TabPages[0]).Enabled = false; } #endregion Handling tab control. dgvPOLine.Rows.Clear(); dataGridView1.Rows.Clear(); if (model.InsertState) { UnLockHeaderControl(); } else { if (HeadContent.StoreInFlag == "1" || HeadContent.ImexConfirm == "1") { LockHeaderControl(); if (HeadContent.StoreInFlag == "1") { butArticleDetail.Enabled = false; toolStripButton1.Visible = false; } } else { UnLockHeaderControl(); butArticleDetail.Enabled = true; toolStripButton1.Visible = true; butSupplier.Enabled = false; txtSupplierCode.ReadOnly = true; butMaker.Enabled = false; txtMakerCode.ReadOnly = true; butMill.Enabled = false; txtMillCode.ReadOnly = true; butCustomer.Enabled = false; txtCustID.ReadOnly = true; cmdCurrencyCode.Enabled = false; if (model.ImportFlag == 0 && HeadContent.ImexConfirm == "2") { panel4.Visible = true; txtIMEXRemark.ReadOnly = true; } } if (model.ImexConfirm == "1") { chkConfirm.Checked = true; } else { chkConfirm.Checked = false; } IEnumerable<StoreInPlanDetailModel> result = new List<StoreInPlanDetailModel>(); if (model.ImportFlag == 2) { result = _repo.GetDetailArticleITAKU(HeadContent.StoreInPlanId); SetItakuDetail(result); } else { model.StoreInPlanDetails = _repo.GetDetail(HeadContent.StoreInPlanId).ToList(); SetDetail(model.StoreInPlanDetails); if (dgvPOLine.Rows.Count >= 1) { IEnumerable<StoreInPlanDetailModel> resultArtcle = this._repo.GetDetailArticle(this.HeadContent.StoreInPlanId, Convert.ToInt32(this.dgvPOLine.Rows[0].Cells[2].Value.ToString())); SetDetailArticle(resultArtcle); } } } if (!HeadContent.InsertState) { butChooseFile.Enabled = false; } else { butChooseFile.Enabled = true; } if (IMEXReviewFlag == true) { toolStripDropDownButton1.Enabled = false; mnuNew.Enabled = false; mnuEditClear.Enabled = false; actionToolStripMenuItem.Enabled = false; toolStripButton1.Enabled = false; tlbClear.Enabled = false; panel4.Visible = true; txtIMEXRemark.ReadOnly = false; butArticleDetail.Enabled = false; } txtNumberOfArticle.DataBindings.Add("Text", model, "NumberOfRcv", true, DataSourceUpdateMode.OnPropertyChanged, 0, "#,##0"); }
private void button1_Click(object sender, EventArgs e) { var list = _repo.GetAll(0).ToList(); using (StoreInPlanDialog frm = new StoreInPlanDialog(epiSession, list)) { frm.ShowDialog(); if (frm.HeadContent.StoreInPlanNum != null) { HeadContent = frm.HeadContent; ModelClone = (StoreInPlanHeadModel)HeadContent.Clone(); } } txtStoreInPlanNum.Text = HeadContent.StoreInPlanNum; SetHeaderContent(HeadContent); }
private void GetNew(int ImportFlag) { //tabControl1.TabPages.Remove(tabPage1); //tabControl1.TabPages.Remove(tabPage2); HeadContent = new StoreInPlanHeadModel(); HeadContent.InsertState = true; HeadContent.StoreInPlanId = 0; HeadContent.StoreInPlanNum = ""; HeadContent.InvoiceDate = DateTime.Now; HeadContent.ETADate = DateTime.Now; HeadContent.ETDDate = DateTime.Now; HeadContent.StoreInFlag = "0"; HeadContent.Currencies = _repoCurr.GetAll().ToList(); HeadContent.ImportPorts = this._repoPort.GetAll().ToList(); HeadContent.ImportFlag = ImportFlag; HeadContent.OpenOrder = 1; ModelClone = (StoreInPlanHeadModel)HeadContent.Clone(); SetHeaderContent(HeadContent); }
private void txtStoreInPlanNum_Leave(object sender, EventArgs e) { string code = txtStoreInPlanNum.Text.Trim(); if (code != ModelClone.StoreInPlanNum && txtStoreInPlanNum.Text != "") { var result = _repo.GetByID(code); if (result == null) { button1_Click(sender, e); } else { HeadContent = result; ModelClone = (StoreInPlanHeadModel)HeadContent.Clone(); } //SetHeaderContent(HeadContent); } }
private void tlbSave_Click(object sender, EventArgs e) { #region Store In has not done. bool error = false; string AttErr = string.Empty; string MessegeErr = string.Empty; if (HeadContent.StoreInFlag == "0") { #region ITAKU if (HeadContent.ImportFlag == 2) { if (!ValidateGridCell(ref dataGridView2)) { error = false; } else { error = true; } } #endregion ITAKU #region Import & Domestic else { if (HeadContent.ValidHeader(epiSession, out AttErr, out MessegeErr)) { if (HeadContent.ImexConfirm == null) { HeadContent.ImexConfirm = "0"; } #region ถ้าเป็นการ Review ของ IMEX if (IMEXReviewFlag) { if (HeadContent.ImexConfirm == "0" || HeadContent.ImexConfirm == "3") { if (chkConfirm.Checked) { if (MessageBox.Show("Are you sure to confirm.", "Question?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { HeadContent.ImexConfirm = "1"; } } else { if (MessageBox.Show("Are you sure to reject.", "Question?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { HeadContent.ImexConfirm = "2"; HeadContent.ImexRemark = txtIMEXRemark.Text; } } } HeadContent.UserGroup = "IMEX"; } #endregion ถ้าเป็นการ Review ของ IMEX #region ไม่ใช่การ Review ของ IMEX หมายถึงผู้ทำรายการเป็นแผนกอื่นที่ไม่ใช่ IMEX else { #region ถ้าสถานะ IMEX = Reject if (HeadContent.ImexConfirm == "2") { if (MessageBox.Show("Are you sure to reply to IMEX.", "Question?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { //Set สถานะเป็น Sale reply to IMEX HeadContent.ImexConfirm = "3"; HeadContent.ImexRemark = txtIMEXRemark.Text + Environment.NewLine + "Sale Reply on Date: " + DateTime.Now.ToLongDateString() + " Time: " + DateTime.Now.ToLongTimeString(); } } #endregion ถ้าสถานะ IMEX = Reject HeadContent.UserGroup = "Sale"; } #endregion ไม่ใช่การ Review ของ IMEX หมายถึงผู้ทำรายการเป็นแผนกอื่นที่ไม่ใช่ IMEX } else { error = true; } } #endregion Import & Domestic if (!error) { HeadContent.CurrencyCode = cmdCurrencyCode.Text.Trim(); HeadContent = _repo.SaveHead(HeadContent, epiSession); UpdateArticleLine(); SetHeaderContent(HeadContent); } } #endregion Store In has not done. }
private void tlbClear_Click(object sender, EventArgs e) { ClearHeaderContent(); ClearPOLineTrans(); dataGridView2.Rows.Clear(); dataGridView2.ReadOnly = true; txtFilePath.Clear(); cmdSheet.DataSource = null; this.HeadContent = new StoreInPlanHeadModel(); this.ModelClone = new StoreInPlanHeadModel(); HeadContent.StoreInFlag = null; HeadContent.InvoiceDate = DateTime.Now; HeadContent.ETADate = DateTime.Now; HeadContent.ETDDate = DateTime.Now; ModelClone = (StoreInPlanHeadModel)HeadContent.Clone(); LockHeaderControl(); }
private void StoreInPlan_Load(object sender, EventArgs e) { if (epiSession.SessionID == null) { Login frm = new Login(); frm.ShowDialog(); } else if (epiSession.SessionID == "x") { this.Close(); this.Dispose(); Environment.Exit(1); } else { //this.Text = epiSession.PlantName; if (HeadContent.StoreInPlanId == 0 && HeadContent != null) { HeadContent.InvoiceDate = DateTime.Now; HeadContent.ETADate = DateTime.Now; HeadContent.ETDDate = DateTime.Now; } else { txtStoreInPlanNum.Text = HeadContent.StoreInPlanNum; SetHeaderContent(HeadContent); } ModelClone = (StoreInPlanHeadModel)HeadContent.Clone(); LockHeaderControl(); return; } StoreInPlan_Load(sender, e); }