public int Insert(AccessStudentOperationModel model) { try { using (SqlConnection conn = new SqlConnection(new SuppConnection().Supp_con)) { conn.Open(); SqlCommand cmd = new SqlCommand("[Resource_Control].[sp_InsertAccessStudentOperation]", conn) { CommandType = CommandType.StoredProcedure }; cmd.Parameters.Add(new SqlParameter("@studentCode", model.StudentCode)); cmd.Parameters.Add(new SqlParameter("@studentName", model.StudentName)); cmd.Parameters.Add(new SqlParameter("@term", model.Term)); cmd.Parameters.Add(new SqlParameter("@flagAllowSelectUnit", model.FlagAllowSelectUnit)); cmd.Parameters.Add(new SqlParameter("@flagAllowFinancial", model.FlagAllowFinancial)); SqlDataAdapter da = new SqlDataAdapter(cmd); DataTable dt = new DataTable(); da.Fill(dt); da.Dispose(); return(int.Parse(dt.Rows[0][0].ToString())); } } catch { return(-1); } }
public bool Update(AccessStudentOperationModel access = null) { try { using (SqlConnection conn = new SqlConnection(new SuppConnection().Supp_con)) { conn.Open(); SqlCommand cmd = new SqlCommand("[Resource_Control].[Sp_UpdateAccessStudentOperation]", conn) { CommandType = CommandType.StoredProcedure }; cmd.Parameters.Add(new SqlParameter("@stcode", access.StudentCode)); cmd.Parameters.Add(new SqlParameter("@flagAllowFinancial", access.FlagAllowFinancial)); cmd.Parameters.Add(new SqlParameter("@flagAllowSelectUnit", access.FlagAllowSelectUnit)); cmd.Parameters.Add(new SqlParameter("@term", access.Term)); SqlDataAdapter da = new SqlDataAdapter(cmd); DataTable dt = new DataTable(); da.Fill(dt); da.Dispose(); return(bool.Parse(dt.Rows[0][0].ToString())); } } catch { return(false); } }
protected void btnSave_Click(object sender, EventArgs e) { btnSave.Enabled = false; if (txtStCode.Text.Trim() == "") { return; } DataTable dt = new DataTable(); accessModel.StudentCode = txtStCode.Text.Trim(); accessModel.FlagAllowFinancial = true; accessModel.FlagAllowSelectUnit = false; AccessStudentOperationModel modelOut = operationHandler.GetAStudent(accessModel); if (modelOut != null && modelOut.id > 0) { RadWindowManager1.RadAlert("به این دانشجو اجازه دفاع آنلاین در ترم جاری داده شده است.", 500, 100, "خطا", ""); } else { //save long accept = operationHandler.EnterAStudent(accessModel); if (accept > 0) { var userId = Session[sessionNames.userID_Karbar].ToString(); commonBusiness.InsertIntoUserLog(int.Parse(userId), DateTime.Now.ToString("HH:mm") , 11, 223 , "اجازه به دانشجو برای برگزاری دفاع به صورت آنلاین", int.Parse(txtStCode.Text)); } txtStCode.Text = ""; LblnameStudent.Text = ""; } RfrhgrdDisplayStundetFinancial(); grdDisplayStundetDefenceOnline.Rebind(); }
public List <AccessStudentOperationModel> Select(AccessStudentOperationModel access = null) { try { using (SqlConnection conn = new SqlConnection(new SuppConnection().Supp_con)) { List <AccessStudentOperationModel> model = new List <AccessStudentOperationModel>(); conn.Open(); SqlCommand cmd = new SqlCommand("[Resource_Control].[Sp_GetAccessStudentOperation]", conn) { CommandType = CommandType.StoredProcedure }; cmd.Parameters.Add(new SqlParameter("@stcode", access != null? access.StudentCode:"-1")); cmd.Parameters.Add(new SqlParameter("@term", access != null ? access.Term:"-1")); SqlDataAdapter da = new SqlDataAdapter(cmd); DataTable dt = new DataTable(); da.Fill(dt); da.Dispose(); for (int i = 0; i < dt.Rows.Count; ++i) { model.Add(new AccessStudentOperationModel { id = int.Parse(dt.Rows[i]["id"].ToString()), StudentCode = dt.Rows[i]["StudentCode"].ToString(), StudentName = dt.Rows[i]["StudentName"].ToString(), Term = dt.Rows[i]["Term"].ToString(), FlagAllowFinancial = bool.Parse(dt.Rows[i]["FlagAllowFinancial"].ToString()), FlagAllowSelectUnit = bool.Parse(dt.Rows[i]["FlagAllowSelectUnit"].ToString()) }); } return(model); } } catch { return(new List <AccessStudentOperationModel>()); } }
public long EnterAStudent(AccessStudentOperationModel access) { return(model.Insert(access)); }
public bool UpdateAStudent(AccessStudentOperationModel access) { return(model.Update(access)); }
public AccessStudentOperationModel GetAStudent(AccessStudentOperationModel access) { return(model.Select(access).Where(c => c.StudentCode == access.StudentCode).FirstOrDefault()); }
public List <AccessStudentOperationModel> GetAllForFinancial(AccessStudentOperationModel access) { return(GetAll(access).Where(c => c.FlagAllowFinancial == true).ToList()); }
public List <AccessStudentOperationModel> GetAllForSelectUnit(AccessStudentOperationModel access) { return(GetAll(access).Where(c => c.FlagAllowSelectUnit == true).ToList()); }
public List <AccessStudentOperationModel> GetAll(AccessStudentOperationModel access) { return(model.Select(access)); }