public MOP DeleteMOP(MOP ObjMOP) { int MOPID = 0; try { using (SqlCommand cmd = new SqlCommand()) { cmd.Connection = SQLCon.Sqlconn(); cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = "[USP_D_MOP]"; cmd.Parameters.AddWithValue("@CATEGORYID", ObjMOP.MOPID); cmd.Parameters.AddWithValue("@USERID", ObjMOP.UserID); object objReturn = cmd.ExecuteScalar(); string str = Convert.ToString(objReturn); if (!int.TryParse(str, out MOPID)) { throw new Exception(str); } else { ObjMOP.MOPID = objReturn; } } } catch (Exception ex) { throw new Exception("Error While Deleteing MOP"); } finally { SQLCon.Sqlconn().Close(); } return(ObjMOP); }
public MOP SaveMOP(MOP ObjMOP) { int MOPID = 0; try { using (SqlCommand cmd = new SqlCommand()) { cmd.Connection = SQLCon.Sqlconn(); cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = "[USP_CU_MOP]"; cmd.Parameters.AddWithValue("@MOPID", ObjMOP.MOPID); cmd.Parameters.AddWithValue("@MOPNAME", ObjMOP.MOPNAME); cmd.Parameters.AddWithValue("@USERID", ObjMOP.UserID); object objReturn = cmd.ExecuteScalar(); string str = Convert.ToString(objReturn); if (!int.TryParse(str, out MOPID)) { throw new Exception(str); } else { ObjMOP.MOPID = objReturn; } } } catch (Exception ex) { if (ex.Message.Contains("UC_MOPNAME")) { throw new Exception("MOP Already Exists!!"); } else { throw new Exception("Error While Saving MOP"); } } finally { SQLCon.Sqlconn().Close(); } return(ObjMOP); }
private void btnDelete_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e) { try { var dlgResult = XtraMessageBox.Show("Are you sure want to delete?", "Confirmation!", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning); if (Convert.ToString(dlgResult) == "OK" && gvMOP.FocusedRowHandle >= 0) { ObjMOP = new MOP(); ObjMOP.MOPID = gvMOP.GetFocusedRowCellValue("MOPID"); ObjMOP.UserID = Utility.UserID; ObjMasterRep.DeleteMOP(ObjMOP); gvMOP.DeleteRow(gvMOP.FocusedRowHandle); } } catch (Exception ex) { ErrorMgmt.ShowError(ex); ErrorMgmt.Errorlog.Error(ex); } }