protected void btnAdd_Click(object sender, EventArgs e) { RequestforEditGRNBLL obj = new RequestforEditGRNBLL(); obj.Id = new Guid(this.hfGRNID.Value.ToString()); obj.DateRequested = DateTime.Parse(this.txtDateRequested.Text); obj.Remark = this.txtRemark.Text; obj.Status = (RequestforEditGRNStatus)int.Parse((this.cboStatus.SelectedValue.ToString())); obj.TrackingNo = hfTrackingNo.Value.ToString(); try { if (obj.Update() == true) { this.lblMessage.Text = "Update sucessfull."; return; } else { this.lblMessage.Text = "Unable to Update Data."; return; } } catch { this.lblMessage.Text = " An Error has occured please try again"; return; } }
private void LoadData(Guid Id) { RequestforEditGRNBLL obj = new RequestforEditGRNBLL(); obj = obj.GetById(Id); if (obj != null) { if (obj.Id != null) { hfGRNID.Value = obj.Id.ToString(); } if (obj.GRN_Number != null) { this.txtGRNNo.Text = obj.GRN_Number; } if (obj.DateRequested != null) { this.txtDateRequested.Text = obj.DateRequested.ToString(); } if (obj.Remark != null) { this.txtRemark.Text = obj.Remark; } hfTrackingNo.Value = obj.TrackingNo; this.cboStatus.SelectedValue = ((int)obj.Status).ToString(); } }
protected void btnAdd_Click(object sender, EventArgs e) { bool isSaved = false; RequestforEditGRNBLL objOld = (RequestforEditGRNBLL)ViewState["oldObject"]; if (objOld == null) { this.lblMessage.Text = "An error has occured please try agin"; return; } RequestforEditGRNBLL obj = new RequestforEditGRNBLL(); obj.Id = new Guid(hfId.Value.ToString()); obj.GRNId = new Guid(hfGRNID.Value.ToString()); obj.Status = (RequestforEditGRNStatus)(int.Parse(this.cboStatus.SelectedValue)); obj.Remark = this.txtRemark.Text; obj.DateRequested = DateTime.Parse(this.txtDateRequested.Text); obj.TrackingNo = hfTrackingNo.Value.ToString(); obj.GRN_Number = this.txtGRNNo.Text; RequestforEditGRNStatus oldStatus = (RequestforEditGRNStatus)(int.Parse(this.hfOriginalStatus.Value.ToString())); isSaved = obj.AllowGRNEdit(oldStatus, objOld); if (isSaved == true) { this.lblMessage.Text = "Data updated Successfully."; this.btnEdit.Enabled = false; return; } else { this.lblMessage.Text = "Unable to Update the record please try again."; return; } }
public static bool save(SqlTransaction tran, RequestforEditGRNBLL obj) { try { int AffectedRows = 0; string strSql = "spInsertRequestApprovedGRNEdit"; SqlParameter[] arPar = new SqlParameter[8]; arPar[0] = new SqlParameter("@GRNId", SqlDbType.UniqueIdentifier); arPar[0].Value = obj.GRNId; arPar[1] = new SqlParameter("@RequestedBy", SqlDbType.UniqueIdentifier); arPar[1].Value = obj.RequestedBy; arPar[2] = new SqlParameter("@DateRequested", SqlDbType.DateTime); arPar[2].Value = obj.DateRequested; arPar[3] = new SqlParameter("@Remark", SqlDbType.Text); arPar[3].Value = obj.Remark; arPar[4] = new SqlParameter("@Status", SqlDbType.Int); arPar[4].Value = (int)obj.Status; arPar[5] = new SqlParameter("@TrackingNo", SqlDbType.NVarChar, 50); arPar[5].Value = obj.TrackingNo; arPar[6] = new SqlParameter("@CreatedBy", SqlDbType.UniqueIdentifier); arPar[6].Value = UserBLL.GetCurrentUser(); arPar[7] = new SqlParameter("@Id", SqlDbType.UniqueIdentifier); arPar[7].Value = obj.Id; AffectedRows = SqlHelper.ExecuteNonQuery(tran, strSql, arPar); if (AffectedRows == 1) { return(true); } else { return(false); } } catch (Exception ex) { throw new Exception("Unable to Insert Sampling Data ", ex); } }
protected void btnAdd_Click(object sender, EventArgs e) { bool isSaved = false; RequestforEditGRNBLL obj = new RequestforEditGRNBLL(); obj.GRNId = new Guid(this.hfGRNID.Value.ToString()); obj.RequestedBy = UserBLL.GetCurrentUser(); obj.DateRequested = DateTime.Parse(this.txtDateRequested.Text); obj.Remark = this.txtRemark.Text; obj.Status = RequestforEditGRNStatus.New; isSaved = obj.Add(); if (isSaved == true) { this.lblMessage.Text = "Data Added Successfully."; this.btnAdd.Enabled = false; } else { this.lblMessage.Text = "Data Can't be Added.please check the data and try again"; return; } }
protected void btnSearch_Click1(object sender, EventArgs e) { if (list != null) { list.Clear(); } string GRNNo = string.Empty; string TrackingNo = string.Empty; Nullable <DateTime> from = null; Nullable <DateTime> to = null; Nullable <RequestforEditGRNStatus> status = null; GRNNo = this.txtGRN.Text; TrackingNo = this.txtTrackingNo.Text; try { status = (RequestforEditGRNStatus)int.Parse(this.cboStatus.SelectedValue); } catch { status = null; } try { from = DateTime.Parse(this.txtFrom.Text); } catch { from = null; } try { to = DateTime.Parse(this.txtTo.Text); } catch { to = null; } RequestforEditGRNBLL obj = new RequestforEditGRNBLL(); try { list = obj.Search(GRNNo, TrackingNo, status, from, to); if (list != null) { if (list.Count <= 0) { this.lblMessage.Text = "No recoreds Found"; this.gvGRNEditRequest.DataSource = list; this.gvGRNEditRequest.DataBind(); return; } else { this.gvGRNEditRequest.DataSource = list; this.gvGRNEditRequest.DataBind(); } } else { this.lblMessage.Text = "No recoreds Found"; this.gvGRNEditRequest.DataSource = list; this.gvGRNEditRequest.DataBind(); return; } } catch (Exception ex) { this.lblMessage.Text = ex.Message; } }
public static RequestforEditGRNBLL GetApprovedRequestByGRNID(Guid GRNId) { string strSql = "spGetApprovedGRNEditRequestByGRNID"; SqlDataReader reader = null; SqlParameter[] arPar = new SqlParameter[1]; arPar[0] = new SqlParameter("@GRNId", SqlDbType.UniqueIdentifier); arPar[0].Value = GRNId; SqlConnection conn = null; try { conn = Connection.getConnection(); reader = SqlHelper.ExecuteReader(conn, CommandType.StoredProcedure, strSql, arPar); if (reader.HasRows) { while (reader.Read()) { RequestforEditGRNBLL obj = new RequestforEditGRNBLL(); if (reader["Id"] != DBNull.Value) { obj.Id = new Guid(reader["Id"].ToString()); } if (reader["GRNId"] != DBNull.Value) { obj.GRNId = new Guid(reader["GRNId"].ToString()); } if (reader["RequestedBy"] != DBNull.Value) { obj.RequestedBy = new Guid(reader["RequestedBy"].ToString()); } if (reader["DateRequested"] != DBNull.Value) { obj.DateRequested = DateTime.Parse((reader["DateRequested"].ToString())); } obj.Remark = reader["Remark"].ToString(); if (reader["Status"] != DBNull.Value) { obj.Status = (RequestforEditGRNStatus)(int.Parse(reader["Status"].ToString())); } obj.TrackingNo = reader["Remark"].ToString(); if (reader["TrackingNo"] != DBNull.Value) { obj.TrackingNo = reader["TrackingNo"].ToString(); } return(obj); } return(null); } else { return(null); } } catch (Exception ex) { throw ex; } finally { if (conn.State == ConnectionState.Open) { conn.Close(); } if (reader != null) { reader.Dispose(); } } }
private static List <RequestforEditGRNBLL> SearchHelper(string strSql) { List <RequestforEditGRNBLL> list; SqlDataReader reader; SqlConnection conn = Connection.getConnection(); if (conn == null || conn.State != ConnectionState.Open) { throw new Exception("Invalid database connection."); } reader = SqlHelper.ExecuteReader(conn, CommandType.Text, strSql); if (reader.HasRows) { list = new List <RequestforEditGRNBLL>(); while (reader.Read()) { RequestforEditGRNBLL obj = new RequestforEditGRNBLL(); if (reader["Id"] != DBNull.Value) { obj.Id = new Guid(reader["Id"].ToString()); } if (reader["GRNId"] != DBNull.Value) { obj.GRNId = new Guid(reader["GRNId"].ToString()); } if (reader["RequestedBy"] != DBNull.Value) { obj.RequestedBy = new Guid(reader["RequestedBy"].ToString()); } if (reader["DateRequested"] != DBNull.Value) { obj.DateRequested = DateTime.Parse((reader["DateRequested"].ToString())); } obj.Remark = reader["Remark"].ToString(); if (reader["Status"] != DBNull.Value) { obj.Status = (RequestforEditGRNStatus)(int.Parse(reader["Status"].ToString())); } obj.TrackingNo = reader["Remark"].ToString(); if (reader["TrackingNo"] != DBNull.Value) { obj.TrackingNo = reader["TrackingNo"].ToString(); } if (reader["GRN_Number"] != DBNull.Value) { obj.GRN_Number = reader["GRN_Number"].ToString(); } list.Add(obj); } if (conn.State == ConnectionState.Open) { conn.Close(); } return(list); } else { if (conn.State == ConnectionState.Open) { conn.Close(); } return(null); } }