private void Btn_delete_Click(object sender, System.EventArgs e) { if (!layerAccess.IsCanDelete(_frmMain.userID)) { clsWin.WarningMessage("You dont have permition to access this form, please contact your administrator", "Access Denied"); return; } CurrencyModel Cur; try { if (clsWin.QuestionMessage("Are you sure want to Delete this record?", "Confirm Delete")) { { Cur = new CurrencyModel { Deleted = true, Comp = clsWin.GetComputerName(), UserName = _frmMain.activeuser, LastUpdate = DateTime.Now, }; LayerCurr.DeleteCur(Cur, id); } clsWin.SuccessMessage("Currency has been Delete", "Success"); Btn_refresh.PerformClick(); } } catch (DbEntityValidationException ex) { var errorMessages = ex.EntityValidationErrors .SelectMany(x => x.ValidationErrors) .Select(x => x.ErrorMessage); var exceptionMessage = string.Concat(errorMessages); clsWin.ClearWindowsObJect(panelEx1); clsWin.ErrorMessage((exceptionMessage).ToString(), "Oops"); Btn_refresh.PerformClick(); } }
public bool DeleteCur(CurrencyModel model, string id) { try { ExecuteCommand(cn => { MySqlCommand cmd = new MySqlCommand(@"update currencymodel set deleted=1 where cGUID=@id", cn); cmd.Parameters.AddWithValue("id", id); rst = cmd.ExecuteNonQuery(); }); if (rst == 1) return true; else return false; } catch (Exception) { throw; } }
private void Btn_Save_Click(object sender, System.EventArgs e) { //BomContext db = new BomContext(); CurrencyModel Cur; try { if (LayerCurr.GetCurCD((Txt_Currency_CD.Text),id)) { var exceptionMessage = "Currency Code already exist"; // clsWin.ClearWindowsObJect(panelEx1); clsWin.ErrorMessage((exceptionMessage).ToString(), "Oops"); Txt_Currency_CD.Focus(); return; } if (clsWin.QuestionMessage("Are you sure want to save", "Save Currency")) { if (StatusEdit) { Cur = new CurrencyModel() { CurrencyCD = Txt_Currency_CD.Text, CurrencyName = txt_Currency_Name.Text, Comp = clsWin.GetComputerName(), UserName = _frmMain.activeuser, LastUpdate = DateTime.Now, }; LayerCurr.UpdatetCur(Cur,id); } else { Cur = new CurrencyModel() { cGUID = Guid.NewGuid().ToString(), CurrencyCD = Txt_Currency_CD.Text.ToString(), CurrencyName = txt_Currency_Name.Text.ToString(), Comp = clsWin.GetComputerName(), UserName = _frmMain.activeuser, LastUpdate = DateTime.Now }; LayerCurr.InSertCur(Cur); } // db.SaveChanges(); clsWin.SuccessMessage("Currency has been saved", "Success"); Btn_refresh.PerformClick(); } } catch (DbEntityValidationException ex) { var errorMessages = ex.EntityValidationErrors .SelectMany(x => x.ValidationErrors) .Select(x => x.ErrorMessage); var exceptionMessage = string.Concat(errorMessages); clsWin.ClearWindowsObJect(panelEx1); clsWin.ErrorMessage((exceptionMessage).ToString(), "Oops"); Btn_refresh.PerformClick(); } }
public bool UpdatetCur(CurrencyModel model, string id) { try { ExecuteCommand(cn => { MySqlCommand cmd = new MySqlCommand(@"update currencymodel set CurrencyCD=@CurrencyCD, CurrencyName=@CurrencyName,Comp=@Comp,UserName=@username where cGUID=@id", cn); cmd.Parameters.AddWithValue("id", id); cmd.Parameters.AddWithValue("@CurrencyCD", model.CurrencyCD); cmd.Parameters.AddWithValue("@CurrencyName", model.CurrencyName); cmd.Parameters.AddWithValue("@Comp", model.Comp); cmd.Parameters.AddWithValue("@username", model.UserName); rst = cmd.ExecuteNonQuery(); }); if (rst == 1) return true; else return false; } catch (Exception) { throw; } }
public bool InSertCur(CurrencyModel model) { try { ExecuteCommand(cn => { MySqlCommand cmd = new MySqlCommand(@"Insert Into currencymodel (cGUID,CurrencyCD,CurrencyName,Comp,UserName) values(@cGUID,@CurrencyCD,@CurrencyName,@Comp,@username)", cn); cmd.Parameters.AddWithValue("cGUID", model.cGUID); cmd.Parameters.AddWithValue("@CurrencyCD", model.CurrencyCD); cmd.Parameters.AddWithValue("@CurrencyName", model.CurrencyName); cmd.Parameters.AddWithValue("@Comp", model.Comp); cmd.Parameters.AddWithValue("@username", model.UserName); rst = cmd.ExecuteNonQuery(); }); if (rst == 1) return true; else return false; } catch (Exception) { throw; } }