public void LoadIBTEdit() { //Rp.IBTRepository ir = new Rp.IBTRepository(); //Acms.Core.Domain.IBT ibt = ir.GetIBTById(nIBTNo); ACMSLogic.InterBranchTransfer.InterBranchTransfer ibt = new ACMSLogic.InterBranchTransfer.InterBranchTransfer(); DataTable dt = ibt.GetIBTById(nIBTNo); this.GetIBTDetail(); this.dateEdit1.EditValue = Convert.ToDateTime(dt.Rows[0]["dtDate"].ToString()).ToShortDateString(); //ibt.DtDate.ToShortDateString(); this.lkBranchTo.EditValue = dt.Rows[0]["strBranchCodeTo"].ToString(); //ibt.BranchTo.Id; this.txtRemarks.Text = dt.Rows[0]["strRemarks"].ToString(); //ibt.StrRemarks; this.simpleButton1.Text = "Update"; this.simpleButton2.Text = "Cancel"; this.simpleButton2.Width = 75; //this.simpleButton3.Visible=false; }
/// <summary> /// Delete IBT Detail /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void simpleButton3_Click(object sender, System.EventArgs e) { if (simpleButton1.Text == "Save") { this.gridView1.DeleteRow(gridView1.FocusedRowHandle); return; } else if (simpleButton1.Text == "Update") { DataRow dr = gridView1.GetDataRow(gridView1.FocusedRowHandle); if (dr.Table.Rows.Count == 1) { MessageBox.Show("Not allow to Delete all entries", "Warning"); return; } if (this.lkBranchTo.EditValue.ToString() == "Select Branch" | this.lkBranchTo.EditValue.ToString() == "") { ACMS.Utils.UI.ShowErrorMessage(this, "Please select valid Branch Code", "Error"); } else { if (MessageBox.Show(this, "Delete this Item? " + dr[0].ToString(), "Confirm", MessageBoxButtons.YesNo) == DialogResult.Yes) { SqlConnection sqlcon = new SqlConnection(SqlHelperUtils.connectionString); sqlcon.Open(); SqlTransaction trans = sqlcon.BeginTransaction(); ACMSLogic.InterBranchTransfer.InterBranchTransfer ibts = new ACMSLogic.InterBranchTransfer.InterBranchTransfer(); if (ibts.DeleteIBTEntries(trans, NIBTNo, ACMS.Convert.ToDBInt32(dr["nEntryID"]), this.terminalUser.Branch.Id)) { this.gridView1.DeleteRow(gridView1.FocusedRowHandle); } trans.Commit(); sqlcon.Close(); this.gridView1.RefreshData(); //this.DialogResult = DialogResult.OK; } } } }
private void GetIBTDetail() { // Rp.IBTRepository ir = new Rp.IBTRepository(); // IList list = ir.GetIBTDetailList(nIBTNo); // //IList list = ir.Find("from IBTEntry s left outer join s.Product_StrItemCode p where s.IBT.Id="+nIBTNo); // // DataTable dt = new DataTable(); // CSLA.Data.ObjectAdapter oa = new CSLA.Data.ObjectAdapter(); // oa.Fill(dt,list); ACMSLogic.InterBranchTransfer.InterBranchTransfer ibt = new ACMSLogic.InterBranchTransfer.InterBranchTransfer(); DataTable dt = ibt.GetIBTDetail(nIBTNo); this.gridControl1.DataSource = dt; this.gridView1.Columns[0].OptionsColumn.AllowEdit = false; this.lkBranchTo.Enabled = false; this.dateEdit1.Enabled = false; this.simpleButton4.Visible = false; }
/// <summary> /// Delete IBT Detail /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void simpleButton3_Click(object sender, System.EventArgs e) { if (simpleButton1.Text=="Save") { this.gridView1.DeleteRow(gridView1.FocusedRowHandle); return; } else if (simpleButton1.Text=="Update") { DataRow dr = gridView1.GetDataRow(gridView1.FocusedRowHandle); if (dr.Table.Rows.Count==1) { MessageBox.Show("Not allow to Delete all entries","Warning"); return; } if(this.lkBranchTo.EditValue.ToString()=="Select Branch" |this.lkBranchTo.EditValue.ToString()=="" ) { ACMS.Utils.UI.ShowErrorMessage(this,"Please select valid Branch Code","Error"); } else { if (MessageBox.Show(this, "Delete this Item? "+ dr[0].ToString(), "Confirm", MessageBoxButtons.YesNo) == DialogResult.Yes) { SqlConnection sqlcon = new SqlConnection(SqlHelperUtils.connectionString); sqlcon.Open(); SqlTransaction trans = sqlcon.BeginTransaction(); ACMSLogic.InterBranchTransfer.InterBranchTransfer ibts = new ACMSLogic.InterBranchTransfer.InterBranchTransfer(); if(ibts.DeleteIBTEntries(trans,NIBTNo,ACMS.Convert.ToDBInt32(dr["nEntryID"]),this.terminalUser.Branch.Id)) { this.gridView1.DeleteRow(gridView1.FocusedRowHandle); } trans.Commit(); sqlcon.Close(); this.gridView1.RefreshData(); //this.DialogResult = DialogResult.OK; } } } }
private void simpleButton1_Click(object sender, System.EventArgs e) { DataRow dr = gridView1.GetDataRow(gridView1.FocusedRowHandle); try { if (dr.Table.Rows.Count==0) { MessageBox.Show("Not allowed to Save Empty Entries","Warning"); return; } } catch (Exception ex) { return; } SqlConnection sqlcon = new SqlConnection(SqlHelperUtils.connectionString); sqlcon.Open(); SqlTransaction trans = sqlcon.BeginTransaction(); if(this.lkBranchTo.EditValue.ToString()=="Select Branch" | this.lkBranchTo.EditValue.ToString()=="") { ACMS.Utils.UI.ShowErrorMessage(this,"Please select valid Branch Code","Error"); } else if(canSave) { ACMSLogic.InterBranchTransfer.InterBranchTransfer ibts = new ACMSLogic.InterBranchTransfer.InterBranchTransfer(); int nIBTNo = 0; //Hashtable htIBT = new Hashtable(); //htint if(isEdit) { if(!ibts.UpdateIBT(trans,DateTime.Now,this.terminalUser.Branch.Id,this.lkBranchTo.EditValue.ToString(),0,this.employee.Id,DateTime.Now,this.txtRemarks.Text,this.nIBTNo)) { trans.Rollback(); sqlcon.Close(); UI.ShowErrorMessage(this,"RollBack Transaction - Update IBT","Error"); return; } ACMSLogic.AuditTrail.AuditTrail audit = new ACMSLogic.AuditTrail.AuditTrail(); audit.SaveAuditTrail(trans,8,"Update IBT "+this.nIBTNo,"IBT",this.employee.Id); } else { nIBTNo = ibts.SaveIBT(trans,DateTime.Now,this.terminalUser.Branch.Id,this.lkBranchTo.EditValue.ToString(),0,this.employee.Id,DateTime.Now,this.txtRemarks.Text); ACMSLogic.AuditTrail.AuditTrail audit = new ACMSLogic.AuditTrail.AuditTrail(); audit.SaveAuditTrail(trans,8,"Save IBT "+this.nIBTNo,"IBT",this.employee.Id); #region nHibernate Code // //DateTime // htIBT.Add("dtDate",DateTime.Now); // //int // //Status 0 - Pending Request // htIBT.Add("nStatusID",0); // //DateTime // htIBT.Add("dtLastEditDate",DateTime.Now); // //string // htIBT.Add("strRemarks",this.txtRemarks.Text); // // //string // htIBT.Add("Branch_strBranchCodeFrom",this.terminalUser.Branch.Id); // // //string // htIBT.Add("Branch_strBranchCodeTo",this.lkBranchTo.EditValue); // // //int // htIBT.Add("Employee_nEmployeeID",this.employee.Id); #endregion } ArrayList ibtEntryList = new ArrayList(); ArrayList ibtProductTransferList = new ArrayList(); DevExpress.XtraGrid.Columns.GridColumn col1 = gridView1.Columns.ColumnByFieldName("strItemCode"); DevExpress.XtraGrid.Columns.GridColumn col2 = gridView1.Columns.ColumnByFieldName("nQuantity"); DevExpress.XtraGrid.Columns.GridColumn col3 = gridView1.Columns.ColumnByFieldName("nEntryID"); for(int i=0;i<this.gridView1.DataRowCount;i++) { object cellValue1 = gridView1.GetRowCellValue(i, col1); object cellValue2 = gridView1.GetRowCellValue(i, col2); object cellValue3 = null; IBTProductTransfer ibt; int nEntryID = 0; string strProductCode = cellValue1.ToString(); int quantity = Convert.ToInt32(cellValue2.ToString()); if(isEdit) { cellValue3 = gridView1.GetRowCellValue(i, col3); nEntryID = Convert.ToInt32(cellValue3); ibt = new IBTProductTransfer(strProductCode,quantity,nEntryID); } else { ibt = new IBTProductTransfer(strProductCode,quantity); } if(ibtProductTransferList.Count==0) { ibtProductTransferList.Add(ibt); } else { bool duplicate=false; for(int _i=0;_i<ibtProductTransferList.Count;_i++) { IBTProductTransfer _ibt = ibtProductTransferList[_i] as IBTProductTransfer; if(strProductCode==_ibt.StrProductCode) { _ibt.Quantity=_ibt.Quantity+quantity; duplicate=true; } } if(!duplicate) ibtProductTransferList.Add(ibt); } } //Variable Hashtable //bool doubleCheckCanSave=true; if(isEdit) { foreach(IBTProductTransfer ibt in ibtProductTransferList) { if(!ibts.UpdateIBTEntries(trans,NIBTNo,ibt.StrProductCode,ibt.Quantity,this.terminalUser.Branch.Id,ibt.NEntryID)) { trans.Rollback(); sqlcon.Close(); UI.ShowErrorMessage(this,"RollBack Transaction - Update IBTEntries","Error"); return; } } ACMSLogic.AuditTrail.AuditTrail audit = new ACMSLogic.AuditTrail.AuditTrail(); audit.SaveAuditTrail(trans,8,"Update IBTEntries "+NIBTNo,"IBTEntries",this.employee.Id); UI.ShowMessage(this,"Record Has Been Updated"); } else { if(nIBTNo!=0) { foreach(IBTProductTransfer ibt in ibtProductTransferList) { if(!ibts.SaveIBTEntries(trans,nIBTNo,ibt.StrProductCode,ibt.Quantity,this.terminalUser.Branch.Id)) { trans.Rollback(); sqlcon.Close(); UI.ShowErrorMessage(this,"RollBack Transaction - Update StockRequestEntries","Error"); return; } #region nHibernate Code // Hashtable htIBTEntries = new Hashtable(); // // htIBTEntries.Add("strItemCode",ibt.StrProductCode); // //int // htIBTEntries.Add("nQuantity",ibt.Quantity); // // Rp.ProductRepository pr = new Rp.ProductRepository(); // // Acms.Core.Domain.ProductInventory pi = pr.CheckQuantityAvailable(ibt.StrProductCode,this.terminalUser.Branch.Id); // if(pi!=null) // { // // if(!pi.IsValidQuantityRequest(ibt.Quantity)) // { // doubleCheckCanSave=false; // //return; // } // } // // ibtEntryList.Add(htIBTEntries); #endregion } ACMSLogic.AuditTrail.AuditTrail audit = new ACMSLogic.AuditTrail.AuditTrail(); audit.SaveAuditTrail(trans,8,"Save IBTEntries "+NIBTNo,"IBTEntries",this.employee.Id); } UI.ShowMessage(this,"Record Has Been Saved"); } } trans.Commit(); sqlcon.Close(); this.DialogResult = DialogResult.OK; }
private void GetIBTDetail() { // Rp.IBTRepository ir = new Rp.IBTRepository(); // IList list = ir.GetIBTDetailList(nIBTNo); // //IList list = ir.Find("from IBTEntry s left outer join s.Product_StrItemCode p where s.IBT.Id="+nIBTNo); // // DataTable dt = new DataTable(); // CSLA.Data.ObjectAdapter oa = new CSLA.Data.ObjectAdapter(); // oa.Fill(dt,list); ACMSLogic.InterBranchTransfer.InterBranchTransfer ibt = new ACMSLogic.InterBranchTransfer.InterBranchTransfer(); DataTable dt = ibt.GetIBTDetail(nIBTNo); this.gridControl1.DataSource = dt; this.gridView1.Columns[0].OptionsColumn.AllowEdit=false; this.lkBranchTo.Enabled=false; this.dateEdit1.Enabled=false; this.simpleButton4.Visible=false; }
public void LoadIBTEdit() { //Rp.IBTRepository ir = new Rp.IBTRepository(); //Acms.Core.Domain.IBT ibt = ir.GetIBTById(nIBTNo); ACMSLogic.InterBranchTransfer.InterBranchTransfer ibt = new ACMSLogic.InterBranchTransfer.InterBranchTransfer(); DataTable dt = ibt.GetIBTById(nIBTNo); this.GetIBTDetail(); this.dateEdit1.EditValue = Convert.ToDateTime(dt.Rows[0]["dtDate"].ToString()).ToShortDateString();//ibt.DtDate.ToShortDateString(); this.lkBranchTo.EditValue = dt.Rows[0]["strBranchCodeTo"].ToString();//ibt.BranchTo.Id; this.txtRemarks.Text = dt.Rows[0]["strRemarks"].ToString();//ibt.StrRemarks; this.simpleButton1.Text="Update"; this.simpleButton2.Text="Cancel"; this.simpleButton2.Width = 75; //this.simpleButton3.Visible=false; }
private void simpleButton1_Click(object sender, System.EventArgs e) { DataRow dr = gridView1.GetDataRow(gridView1.FocusedRowHandle); try { if (dr.Table.Rows.Count == 0) { MessageBox.Show("Not allowed to Save Empty Entries", "Warning"); return; } } catch (Exception ex) { return; } SqlConnection sqlcon = new SqlConnection(SqlHelperUtils.connectionString); sqlcon.Open(); SqlTransaction trans = sqlcon.BeginTransaction(); if (this.lkBranchTo.EditValue.ToString() == "Select Branch" | this.lkBranchTo.EditValue.ToString() == "") { ACMS.Utils.UI.ShowErrorMessage(this, "Please select valid Branch Code", "Error"); } else if (canSave) { ACMSLogic.InterBranchTransfer.InterBranchTransfer ibts = new ACMSLogic.InterBranchTransfer.InterBranchTransfer(); int nIBTNo = 0; //Hashtable htIBT = new Hashtable(); //htint if (isEdit) { if (!ibts.UpdateIBT(trans, DateTime.Now, this.terminalUser.Branch.Id, this.lkBranchTo.EditValue.ToString(), 0, this.employee.Id, DateTime.Now, this.txtRemarks.Text, this.nIBTNo)) { trans.Rollback(); sqlcon.Close(); UI.ShowErrorMessage(this, "RollBack Transaction - Update IBT", "Error"); return; } ACMSLogic.AuditTrail.AuditTrail audit = new ACMSLogic.AuditTrail.AuditTrail(); audit.SaveAuditTrail(trans, 8, "Update IBT " + this.nIBTNo, "IBT", this.employee.Id); } else { nIBTNo = ibts.SaveIBT(trans, DateTime.Now, this.terminalUser.Branch.Id, this.lkBranchTo.EditValue.ToString(), 0, this.employee.Id, DateTime.Now, this.txtRemarks.Text); ACMSLogic.AuditTrail.AuditTrail audit = new ACMSLogic.AuditTrail.AuditTrail(); audit.SaveAuditTrail(trans, 8, "Save IBT " + this.nIBTNo, "IBT", this.employee.Id); #region nHibernate Code // //DateTime // htIBT.Add("dtDate",DateTime.Now); // //int // //Status 0 - Pending Request // htIBT.Add("nStatusID",0); // //DateTime // htIBT.Add("dtLastEditDate",DateTime.Now); // //string // htIBT.Add("strRemarks",this.txtRemarks.Text); // // //string // htIBT.Add("Branch_strBranchCodeFrom",this.terminalUser.Branch.Id); // // //string // htIBT.Add("Branch_strBranchCodeTo",this.lkBranchTo.EditValue); // // //int // htIBT.Add("Employee_nEmployeeID",this.employee.Id); #endregion } ArrayList ibtEntryList = new ArrayList(); ArrayList ibtProductTransferList = new ArrayList(); DevExpress.XtraGrid.Columns.GridColumn col1 = gridView1.Columns.ColumnByFieldName("strItemCode"); DevExpress.XtraGrid.Columns.GridColumn col2 = gridView1.Columns.ColumnByFieldName("nQuantity"); DevExpress.XtraGrid.Columns.GridColumn col3 = gridView1.Columns.ColumnByFieldName("nEntryID"); for (int i = 0; i < this.gridView1.DataRowCount; i++) { object cellValue1 = gridView1.GetRowCellValue(i, col1); object cellValue2 = gridView1.GetRowCellValue(i, col2); object cellValue3 = null; IBTProductTransfer ibt; int nEntryID = 0; string strProductCode = cellValue1.ToString(); int quantity = Convert.ToInt32(cellValue2.ToString()); if (isEdit) { cellValue3 = gridView1.GetRowCellValue(i, col3); nEntryID = Convert.ToInt32(cellValue3); ibt = new IBTProductTransfer(strProductCode, quantity, nEntryID); } else { ibt = new IBTProductTransfer(strProductCode, quantity); } if (ibtProductTransferList.Count == 0) { ibtProductTransferList.Add(ibt); } else { bool duplicate = false; for (int _i = 0; _i < ibtProductTransferList.Count; _i++) { IBTProductTransfer _ibt = ibtProductTransferList[_i] as IBTProductTransfer; if (strProductCode == _ibt.StrProductCode) { _ibt.Quantity = _ibt.Quantity + quantity; duplicate = true; } } if (!duplicate) { ibtProductTransferList.Add(ibt); } } } //Variable Hashtable //bool doubleCheckCanSave=true; if (isEdit) { foreach (IBTProductTransfer ibt in ibtProductTransferList) { if (!ibts.UpdateIBTEntries(trans, NIBTNo, ibt.StrProductCode, ibt.Quantity, this.terminalUser.Branch.Id, ibt.NEntryID)) { trans.Rollback(); sqlcon.Close(); UI.ShowErrorMessage(this, "RollBack Transaction - Update IBTEntries", "Error"); return; } } ACMSLogic.AuditTrail.AuditTrail audit = new ACMSLogic.AuditTrail.AuditTrail(); audit.SaveAuditTrail(trans, 8, "Update IBTEntries " + NIBTNo, "IBTEntries", this.employee.Id); UI.ShowMessage(this, "Record Has Been Updated"); } else { if (nIBTNo != 0) { foreach (IBTProductTransfer ibt in ibtProductTransferList) { if (!ibts.SaveIBTEntries(trans, nIBTNo, ibt.StrProductCode, ibt.Quantity, this.terminalUser.Branch.Id)) { trans.Rollback(); sqlcon.Close(); UI.ShowErrorMessage(this, "RollBack Transaction - Update StockRequestEntries", "Error"); return; } #region nHibernate Code // Hashtable htIBTEntries = new Hashtable(); // // htIBTEntries.Add("strItemCode",ibt.StrProductCode); // //int // htIBTEntries.Add("nQuantity",ibt.Quantity); // // Rp.ProductRepository pr = new Rp.ProductRepository(); // // Acms.Core.Domain.ProductInventory pi = pr.CheckQuantityAvailable(ibt.StrProductCode,this.terminalUser.Branch.Id); // if(pi!=null) // { // // if(!pi.IsValidQuantityRequest(ibt.Quantity)) // { // doubleCheckCanSave=false; // //return; // } // } // // ibtEntryList.Add(htIBTEntries); #endregion } ACMSLogic.AuditTrail.AuditTrail audit = new ACMSLogic.AuditTrail.AuditTrail(); audit.SaveAuditTrail(trans, 8, "Save IBTEntries " + NIBTNo, "IBTEntries", this.employee.Id); } UI.ShowMessage(this, "Record Has Been Saved"); } } trans.Commit(); sqlcon.Close(); this.DialogResult = DialogResult.OK; }