public List <UnitMasterModel> GetListofUnits() { List <UnitMasterModel> lsObj = new List <UnitMasterModel>(); UnitMasterModel obj; try { string Query = "SELECT * from unitmaster"; System.Data.IDataReader dr = _dbHelper.ExecuteDataReader(Query, _dbHelper.GetConnObject()); while (dr.Read()) { //Initialize/reset account master object obj = new UnitMasterModel(); obj.UM_ID = Convert.ToInt32(dr["UM_ID"]); obj.PrintName = dr["PrintName"].ToString(); obj.UnitName = dr["UnitName"].ToString(); obj.ExciseReturn = dr["ExciseReturn"].ToString(); obj.CreatedDate = Convert.ToDateTime(dr["CreatedDate"]); lsObj.Add(obj); } } catch (Exception ex) { throw ex; } return(lsObj); }
private void btnUpdate_Click(object sender, EventArgs e) { if (tbxUnitName.Text.Equals(string.Empty)) { MessageBox.Show("Unit Name can not be blank!"); return; } UnitMasterModel objModel = new UnitMasterModel(); objModel.UnitName = tbxUnitName.Text.Trim(); objModel.PrintName = tbxPrintname.Text.Trim() == null ? string.Empty : tbxPrintname.Text.Trim();; objModel.ExciseReturn = tbxUnitnameExcise.Text.Trim() == null ? string.Empty : tbxUnitnameExcise.Text.Trim();; objModel.UM_ID = UMId; objModel.CreatedBy = "Admin"; bool isSuccess = objunm.UpdateUM(objModel); if (isSuccess) { MessageBox.Show("Update Successfuly!"); ClearControls(); UMId = 0; Administration.List.UnitmasterList frmList = new Administration.List.UnitmasterList(); frmList.StartPosition = FormStartPosition.CenterScreen; frmList.ShowDialog(); FillUnitMasterInfo(); } }
public ResultModel Update(UnitMasterModel obj) { ResultModel oOutput = new ResultModel(); try { UnitMaster oUnitMaster = dbSet.Where(m => m.ID == obj.ID).FirstOrDefault(); if (oUnitMaster == null) { oOutput.Status = 0; oOutput.Msg = "Record not exist"; } else { // Removing Already Added Mapper.Map(obj, oUnitMaster); oDB.SaveChanges(); oOutput.Data = Mapper.Map <UnitMasterModel>(oUnitMaster); } } catch (Exception ex) { oOutput.Status = 0; oOutput.Msg = "Data access error"; Services.Utitilty.Error(ex); } return(oOutput); }
private void btnSave_Click(object sender, EventArgs e) { if (tbxUnitName.Text.Equals(string.Empty)) { MessageBox.Show("Unit Name can not be blank!"); return; } //if (accObj.IsGroupExists(tbxGroupName.Text.Trim())) //{ // MessageBox.Show("Group Name already Exists!", "SunSpeed", MessageBoxButtons.RetryCancel); // cbxUnderGrp.Focus(); // return; //} UnitMasterModel objModel = new UnitMasterModel(); objModel.UnitName = tbxUnitName.Text.Trim(); objModel.PrintName = tbxPrintname.Text.Trim(); objModel.ExciseReturn = tbxUnitName.Text.Trim(); objModel.CreatedBy = "Admin"; bool isSuccess = objunm.SaveUM(objModel); if (isSuccess) { MessageBox.Show("Saved Successfuly!"); } //List<UnitMasterModel> lstUnits = objunm.GetListofUnits(); //dgvList.DataSource = lstUnits; //Dialogs.PopUPDialog d = new Dialogs.PopUPDialog("Saved Successfully!"); //d.ShowDialog(); }
public ResultModel Insert(UnitMasterModel obj) { ResultModel oOutput = new ResultModel(); try { UnitMaster oUnitMaster = Mapper.Map <UnitMaster>(obj); dbSet.Add(oUnitMaster); oDB.SaveChanges(); oOutput.Data = Mapper.Map <UnitMasterModel>(oUnitMaster); } catch (Exception ex) { oOutput.Status = 0; oOutput.Msg = "Data access error"; Services.Utitilty.Error(ex); } return(oOutput); }
private void FillUnitMasterInfo() { if (UMId == 0) { tbxUnitName.Focus(); lblUpdate.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.OnlyInCustomization; lblDelete.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.OnlyInCustomization; lblSave.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Always; return; } UnitMasterModel objunit = objunm.GetListofUnitsById(UMId); tbxUnitName.Text = objunit.UnitName; tbxPrintname.Text = objunit.PrintName; tbxUnitnameExcise.Text = objunit.ExciseReturn; lblUpdate.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Always; lblDelete.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Always; lblSave.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.OnlyInCustomization; tbxUnitName.Focus(); }
private void btnSave_Click(object sender, EventArgs e) { if (tbxUnitName.Text.Equals(string.Empty)) { MessageBox.Show("Unit Name can not be blank!"); return; } UnitMasterModel objModel = new UnitMasterModel(); objModel.UnitName = tbxUnitName.Text.Trim(); objModel.PrintName = tbxPrintname.Text == null?string.Empty:tbxPrintname.Text.Trim(); objModel.ExciseReturn = tbxUnitnameExcise.Text.Trim() == null ? string.Empty : tbxUnitnameExcise.Text.Trim(); objModel.CreatedBy = "Admin"; bool isSuccess = objunm.SaveUM(objModel); if (isSuccess) { MessageBox.Show("Saved Successfuly!"); ClearControls(); tbxUnitName.Focus(); } }
public UnitMasterModel GetListofUnitsById(int id) { UnitMasterModel obj = new UnitMasterModel(); try { string Query = "SELECT * FROM `UnitMaster` WHERE UM_ID=" + id + ""; System.Data.IDataReader dr = _dbHelper.ExecuteDataReader(Query, _dbHelper.GetConnObject()); while (dr.Read()) { obj.UM_ID = Convert.ToInt32(dr["UM_ID"]); obj.UnitName = dr["UnitName"].ToString(); obj.PrintName = dr["PrintName"].ToString(); obj.ExciseReturn = dr["ExciseReturn"].ToString(); } } catch (Exception ex) { throw ex; } return(obj); }
public ResultModel Delete([FromBody] UnitMasterModel obj) { return(_svr.Delete(obj.ID)); }
public ResultModel Put([FromBody] UnitMasterModel obj) { return(_svr.Update(obj)); }
public ResultModel Post([FromBody] UnitMasterModel obj) { return(_svr.Insert(obj)); }