//UPDATE public bool UpdateCCM(CostCentreMasterModel objCCM) { string Query = string.Empty; bool isUpdated = true; try { DBParameterCollection paramCollection = new DBParameterCollection(); paramCollection.Add(new DBParameter("@Name", objCCM.Name)); paramCollection.Add(new DBParameter("@Alias", objCCM.Alias)); paramCollection.Add(new DBParameter("@Group", objCCM.Group)); paramCollection.Add(new DBParameter("@opBal", objCCM.opBal, System.Data.DbType.Decimal)); paramCollection.Add(new DBParameter("@DrCr", objCCM.DrCr)); paramCollection.Add(new DBParameter("@ModifiedBy", objCCM.ModifiedBy)); paramCollection.Add(new DBParameter("@CCM_ID", objCCM.CCM_ID)); Query = "UPDATE CostCentreMaster SET Name=@Name,Alias=@Alias,`Group`=@Group,opBal=@opBal,DrCr=@DrCr,ModifiedBy=@ModifiedBy " + "WHERE CCM_ID=@CCM_ID"; if (_dbHelper.ExecuteNonQuery(Query, paramCollection) > 0) { isUpdated = true; } } catch (Exception ex) { isUpdated = false; throw ex; } return(isUpdated); }
//Save public bool SaveCCM(CostCentreMasterModel objCCM) { string Query = string.Empty; bool isSaved = true; try { DBParameterCollection paramCollection = new DBParameterCollection(); paramCollection.Add(new DBParameter("@Name", objCCM.Name)); paramCollection.Add(new DBParameter("@Alias", objCCM.Alias)); paramCollection.Add(new DBParameter("@Group", objCCM.Group)); paramCollection.Add(new DBParameter("@opBal", objCCM.opBal, System.Data.DbType.Decimal)); paramCollection.Add(new DBParameter("@DrCr", objCCM.DrCr)); paramCollection.Add(new DBParameter("@CreatedBy", objCCM.CreatedBy)); Query = "INSERT INTO CostCentreMaster(`Name`,`Alias`,`Group`,`opBal`,`DrCr`,`CreatedBy`)" + "VALUES(@Name,@Alias,@Group,@opBal,@DrCr,@CreatedBy)"; if (_dbHelper.ExecuteNonQuery(Query, paramCollection) > 0) { isSaved = true; } } catch (Exception ex) { isSaved = false; throw ex; } return(isSaved); }
//List public List <CostCentreMasterModel> GetAllCostCentreMaster() { List <eSunSpeedDomain.CostCentreMasterModel> lstCCM = new List <CostCentreMasterModel>(); eSunSpeedDomain.CostCentreMasterModel objCCM; string Query = "SELECT * FROM CostCentreMaster"; System.Data.IDataReader dr = _dbHelper.ExecuteDataReader(Query, _dbHelper.GetConnObject()); while (dr.Read()) { objCCM = new CostCentreMasterModel(); objCCM.CCM_ID = Convert.ToInt32(dr["CCM_ID"]); objCCM.Name = dr["Name"].ToString(); objCCM.Alias = dr["Alias"].ToString(); objCCM.Group = dr["Group"].ToString(); objCCM.opBal = Convert.ToDecimal(dr["opBal"]); objCCM.DrCr = dr["DrCr"].ToString(); //objCCM.ModifiedBy = dr["ModifiedBy"].ToString(); lstCCM.Add(objCCM); } return(lstCCM); }
private void btnSave_Click(object sender, EventArgs e) { if (tbxName.Text.Equals(string.Empty)) { MessageBox.Show("Cost Center Name can not be blank!"); return; } CostCentreMasterModel objModel = new CostCentreMasterModel(); objModel.Name = tbxName.Text.Trim(); objModel.Alias = tbxAliasname.Text.Trim(); objModel.Group = cbxPrimarygroup.SelectedItem.ToString(); objModel.opBal = Convert.ToDecimal(tbxOpbal.Text.Trim()); objModel.DrCr = cbxDrCr.SelectedItem.ToString(); objModel.CreatedBy = "Admin"; bool isSuccess = objccm.SaveCCM(objModel); if (isSuccess) { MessageBox.Show("Saved Successfully!"); ClearControls(); tbxName.Focus(); } }
private void btnUpdate_Click(object sender, EventArgs e) { CostCentreMasterModel objModel = new CostCentreMasterModel(); objModel.Name = tbxName.Text.Trim(); objModel.Alias = tbxAliasname.Text.Trim(); objModel.Group = cbxPrimarygroup.SelectedItem.ToString(); objModel.opBal = Convert.ToDecimal(tbxOpbal.Text.Trim()); objModel.DrCr = cbxDrCr.SelectedItem.ToString(); objModel.ModifiedBy = "Admin"; objModel.CCM_ID = costId; bool isSuccess = objccm.UpdateCCM(objModel); if (isSuccess) { MessageBox.Show("Update Successfully!"); ClearControls(); costId = 0; Administration.List.CostcenterList frmList = new Administration.List.CostcenterList(); frmList.StartPosition = FormStartPosition.CenterScreen; frmList.ShowDialog(); FillCostCenterInfo(); } }
private void btnSave_Click(object sender, EventArgs e) { if (tbxName.Text.Equals(string.Empty)) { MessageBox.Show("Name can not be blank!"); return; } CostCentreMasterModel objModel = new CostCentreMasterModel(); objModel.Name = tbxName.Text.Trim(); objModel.Alias = tbxAliasname.Text.Trim(); objModel.Group = cbxPrimarygroup.SelectedItem.ToString(); objModel.opBal = Convert.ToDecimal(tbxOpbal.Text.Trim()); objModel.DrCr = cbxDrCr.SelectedItem.ToString(); objModel.CreatedBy = "Admin"; bool isSuccess = objccm.SaveCCM(objModel); if (isSuccess) { MessageBox.Show("Saved Successfully!"); } //List<CostCentreMasterModel> lstCenter = objccm.GetAllCostCentreMaster(); //dgvList.DataSource = lstCenter; //Dialogs.PopUPDialog d = new Dialogs.PopUPDialog("Saved Successfully!"); //d.ShowDialog(); }
private void btnDelete_Click(object sender, EventArgs e) { CostCentreMasterModel objmodel = objMasterBl.GetCostNameByGroupname(tbxGroupName.Text.Trim()); if (objmodel.Name != null) { MessageBox.Show("Can Not Delete Name Under Tag With Cost Name.." + objmodel.Name); tbxGroupName.Focus(); } if (objmodel.Name == null) { bool isDelete = objCG.DeleteCostCenterGroupById(groupId); if (isDelete) { MessageBox.Show("Delete Successfully!"); ClearControls(); groupId = 0; Administration.List.CostcentergrpList frmList = new Administration.List.CostcentergrpList(); frmList.StartPosition = FormStartPosition.CenterScreen; frmList.ShowDialog(); FillCostCenterGroupInfo(); } } }
//Get CostCenterMasterName By CostGroup Name public CostCentreMasterModel GetCostNameByGroupname(string groupname) { CostCentreMasterModel objcostModel = new CostCentreMasterModel(); string Query = string.Empty; Query = "SELECT Name FROM `CostCentreMaster` WHERE `Group`='" + groupname + "'"; System.Data.IDataReader dr = _dbHelper.ExecuteDataReader(Query, _dbHelper.GetConnObject()); while (dr.Read()) { objcostModel = new eSunSpeedDomain.CostCentreMasterModel(); objcostModel.Name = dr["Name"].ToString(); } return(objcostModel); }
public CostCentreMasterModel GetAllCostCentreMasterById(int id) { CostCentreMasterModel objCCM = new CostCentreMasterModel(); string Query = "SELECT * FROM CostCentreMaster WHERE CCM_ID=" + id + ""; System.Data.IDataReader dr = _dbHelper.ExecuteDataReader(Query, _dbHelper.GetConnObject()); while (dr.Read()) { objCCM = new CostCentreMasterModel(); objCCM.CCM_ID = Convert.ToInt32(dr["CCM_ID"]); objCCM.Name = dr["Name"].ToString(); objCCM.Alias = dr["Alias"].ToString(); objCCM.Group = dr["Group"].ToString(); objCCM.opBal = Convert.ToDecimal(dr["opBal"]); objCCM.DrCr = dr["DrCr"].ToString(); //objCCM.ModifiedBy = dr["ModifiedBy"].ToString(); } return(objCCM); }
private void FillCostCenterInfo() { CostCentreMasterModel objMaster = objccm.GetAllCostCentreMasterById(costId); if (costId == 0) { tbxName.Focus(); ClearControls(); lblUpdate.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.OnlyInCustomization; lblSave.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Always; lblDelete.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.OnlyInCustomization; return; } tbxName.Text = objMaster.Name; tbxAliasname.Text = objMaster.Alias; cbxPrimarygroup.SelectedItem = objMaster.Group; tbxOpbal.Text = Convert.ToString(objMaster.opBal); cbxDrCr.SelectedItem = objMaster.DrCr; lblUpdate.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Always; lblSave.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.OnlyInCustomization; lblDelete.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Always; }