예제 #1
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            bool     isSaved = false;
            DateTime dtRecivedDateTime;

            dtRecivedDateTime = DateTime.Parse(this.txtDate.Text + " " + this.txtTime.Text);
            Guid SamplingResultId = Guid.Empty;

            SamplingResultId = new Guid(this.cboSamplingCode.SelectedValue.ToString());
            // Get Related Data.
            ReSamplingBLL objReSampling = new ReSamplingBLL();

            objReSampling.LoadSamplingRealtedData(SamplingResultId, dtRecivedDateTime);
            isSaved = objReSampling.Save();
            if (isSaved == true)
            {
                this.lblmsg.Text     = "Data Updated Successfully.";
                this.btnSave.Enabled = false;
                return;
            }
            else
            {
                this.lblmsg.Text = "Unable to record the data. Please try again.";
                return;
            }
        }
예제 #2
0
        public static ReSamplingBLL GetSamplingRelatedDataBySamplingResultId(Guid SamplingResultId)
        {
            ReSamplingBLL objSample = new ReSamplingBLL();
            SqlDataReader reader;
            string        strSql = "spGetSamplingInfoBySamplingResultId";

            SqlParameter[] arPar = new SqlParameter[1];
            SqlConnection  conn  = new SqlConnection();

            arPar[0]       = new SqlParameter("@SamplingResultId", SqlDbType.UniqueIdentifier);
            arPar[0].Value = SamplingResultId;
            try
            {
                conn   = Connection.getConnection();
                reader = SqlHelper.ExecuteReader(conn, CommandType.StoredProcedure, strSql, arPar);
                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        if (reader["SamplingId"] != DBNull.Value)
                        {
                            try
                            {
                                objSample.SamplingId = new Guid(reader["SamplingId"].ToString());
                            }
                            catch
                            {
                                throw new Exception("Unable to Get Samlping Id.");
                            }
                        }
                        objSample.SamplingResultId = SamplingResultId;
                        if (reader["ReceivigRequestId"] != DBNull.Value)
                        {
                            try
                            {
                                objSample.ReceivigRequestId = new Guid(reader["ReceivigRequestId"].ToString());
                            }
                            catch
                            {
                                throw new Exception("Unable to Get Receivig Request Id.");
                            }
                        }
                    }
                    return(objSample);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (conn.State == ConnectionState.Open)
                {
                    conn.Close();
                }
            }
            return(null);
        }
예제 #3
0
        public static bool Insert(ReSamplingBLL obj, SqlTransaction trans)
        {
            string strSql = "spInsertResamplingRequest";

            SqlParameter[] arPar = new SqlParameter[9];
            try
            {
                arPar[0]       = new SqlParameter("@TransactionId", SqlDbType.NVarChar, 50);
                arPar[0].Value = obj.TrackingNo;

                arPar[1]       = new SqlParameter("@SamplingId", SqlDbType.UniqueIdentifier);
                arPar[1].Value = obj.SamplingId;

                arPar[2]       = new SqlParameter("@ReceivigRequestId", SqlDbType.UniqueIdentifier);
                arPar[2].Value = obj.ReceivigRequestId;

                arPar[3]       = new SqlParameter("@SamplingResultId", SqlDbType.UniqueIdentifier);
                arPar[3].Value = obj.SamplingResultId;

                arPar[4]       = new SqlParameter("@DateTimeRequested", SqlDbType.DateTime);
                arPar[4].Value = obj.DateTimeRequested;

                arPar[5]       = new SqlParameter("@Status", SqlDbType.Int);
                arPar[5].Value = (int)obj.Status;

                arPar[6]       = new SqlParameter("@Remark", SqlDbType.Int);
                arPar[6].Value = obj.Remark;

                arPar[7]       = new SqlParameter("@CreatedBy", SqlDbType.Int);
                arPar[7].Value = obj.CreatedBy;

                arPar[8]       = new SqlParameter("@Id", SqlDbType.UniqueIdentifier);
                arPar[8].Value = obj.Id;

                int AffectedRows = 0;

                AffectedRows = SqlHelper.ExecuteNonQuery(trans, strSql, arPar);
                if (AffectedRows == 1)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #4
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            bool          isSaved = false;
            ReSamplingBLL obj     = new ReSamplingBLL();

            obj.Id = new Guid(this.hfId.Value);
            try
            {
                obj.DateTimeRequested = DateTime.Parse(this.txtDate.Text + " " + this.txtTime.Text);
            }
            catch
            {
                this.lblmsg.Text = "Invalid Date.";
                return;
            }


            int intStatus = int.Parse(this.cboStatus.SelectedValue);

            if (intStatus == 1)
            {
                obj.Status = ReSamplingStatus.New;
            }
            else if (intStatus == 2)
            {
                obj.Status = ReSamplingStatus.Approved;
            }
            else
            {
                obj.Status = ReSamplingStatus.Cancelled;
            }

            obj.LastModifiedBy = UserBLL.GetCurrentUser();
            obj.TrackingNo     = this.hfTrackingNo.Value.ToString();
            try
            {
                isSaved = obj.Update();
            }
            catch (Exception ex)
            {
                this.lblmsg.Text = ex.Message;
            }
            if (isSaved == true)
            {
                Response.Redirect("ListInbox.aspx");
            }
            else
            {
                this.lblmsg.Text = "Unable to update Data";
            }
        }
예제 #5
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (IsPostBack != true)
     {
         Guid Id = Guid.Empty;
         if (Session["ResamplingEdit"] == null)
         {
             this.lblmsg.Text = "Please Try Again.";
             return;
         }
         if (Session["ResamplingEdit"].ToString() == "")
         {
             this.lblmsg.Text = "Please Try Again.";
             return;
         }
         else
         {
             this.hfId.Value = Session["ResamplingEdit"].ToString();
             try
             {
                 Id = new Guid(Session["ResamplingEdit"].ToString());
             }
             catch (Exception ex)
             {
                 this.lblmsg.Text = ex.Message;
             }
             if (Id != Guid.Empty)
             {
                 ReSamplingBLL objResampling = new ReSamplingBLL();
                 objResampling                = objResampling.GetById(Id);
                 this.lblSamplingCode.Text    = objResampling.SampleCode.ToString();
                 this.cboStatus.SelectedValue = ((int)objResampling.Status).ToString();
                 this.txtDate.Text            = objResampling.DateTimeRequested.ToShortDateString();
                 this.txtTime.Text            = objResampling.DateTimeRequested.ToLongTimeString();
                 this.hfTrackingNo.Value      = objResampling.TrackingNo;
             }
         }
     }
 }
예제 #6
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (IsPostBack != true)
     {
         ReSamplingBLL        obj = new ReSamplingBLL();
         List <ReSamplingBLL> list;
         list = obj.GetPendingResampling(UserBLL.GetCurrentWarehouse());
         if (list != null)
         {
             this.cboSamplingCode.Items.Add(new ListItem("Please Select Sampling Code"));
             foreach (ReSamplingBLL item in list)
             {
                 if ((item.SampleCode != 0) && (item.SamplingResultId != Guid.Empty || item.SamplingResultId != null))
                 {
                     this.cboSamplingCode.Items.Add(new ListItem(item.SampleCode.ToString(), item.SamplingResultId.ToString()));
                 }
             }
         }
         else
         {
             this.lblmsg.Text = "No Results Pendindg Resampling.";
         }
     }
 }
예제 #7
0
        public static bool Update(ReSamplingBLL obj, SqlTransaction trans)
        {
            string strSql = "spUpdateReSampling";

            SqlParameter[] arPar = new SqlParameter[4];
            try
            {
                arPar[0]       = new SqlParameter("@Id", SqlDbType.NVarChar, 50);
                arPar[0].Value = obj.Id;

                arPar[1]       = new SqlParameter("@DateTimeRequested", SqlDbType.DateTime);
                arPar[1].Value = obj.DateTimeRequested;

                arPar[2]       = new SqlParameter("@Status", SqlDbType.Int);
                arPar[2].Value = (int)obj.Status;

                arPar[3]       = new SqlParameter("@LastModifiedBy", SqlDbType.UniqueIdentifier);
                arPar[3].Value = obj.LastModifiedBy;

                int AffectedRows = 0;

                AffectedRows = SqlHelper.ExecuteNonQuery(trans, strSql, arPar);
                if (AffectedRows == 1)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #8
0
        public static List <ReSamplingBLL> GetMoistureFailedSamples(Guid WarehouseId)
        {
            string strSql = "spGetMoistureFailedPendingResampling";

            SqlParameter[] arPar = new SqlParameter[1];
            SqlDataReader  reader;

            arPar[0]       = new SqlParameter("@warehouseId", SqlDbType.UniqueIdentifier);
            arPar[0].Value = WarehouseId;
            List <ReSamplingBLL> list;
            SqlConnection        conn = null;

            try
            {
                conn = Connection.getConnection();
                if (conn == null || conn.State != ConnectionState.Open)
                {
                    throw new Exception("Invalid database connection.");
                }
                reader = SqlHelper.ExecuteReader(conn, CommandType.StoredProcedure, strSql, arPar);
                if (reader.HasRows)
                {
                    list = new List <ReSamplingBLL>();
                    while (reader.Read())
                    {
                        ReSamplingBLL obj = new ReSamplingBLL();
                        if (reader["SamplingResultId"] != DBNull.Value)
                        {
                            obj.SamplingResultId = new Guid(reader["SamplingResultId"].ToString());
                        }
                        if (reader["SamplingId"] != DBNull.Value)
                        {
                            obj.SamplingId = new Guid(reader["SamplingId"].ToString());
                        }
                        if (reader["SampleCode"] != DBNull.Value)
                        {
                            try
                            {
                                obj.SampleCode = int.Parse(reader["SampleCode"].ToString());
                            }
                            catch
                            {
                            }
                        }
                        list.Add(obj);
                    }
                    return(list);
                }
                else
                {
                    return(null);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (conn.State == ConnectionState.Open)
                {
                    conn.Close();
                }
            }
        }
예제 #9
0
        public static ReSamplingBLL GetByTrackingNo(string TrackingNo)
        {
            ReSamplingBLL objSample = new ReSamplingBLL();
            SqlDataReader reader;
            string        strSql = "spGetReSamplingByTrackingNo";

            SqlParameter[] arPar = new SqlParameter[1];

            arPar[0]       = new SqlParameter("@TransactionId", SqlDbType.NVarChar, 50);
            arPar[0].Value = TrackingNo;
            SqlConnection conn = null;

            try
            {
                conn   = Connection.getConnection();
                reader = SqlHelper.ExecuteReader(conn, CommandType.StoredProcedure, strSql, arPar);
                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        if (reader["Id"] != DBNull.Value)
                        {
                            try
                            {
                                objSample.Id = new Guid(reader["Id"].ToString());
                            }
                            catch
                            {
                                throw new Exception("Unable to Get Status.");
                            }
                        }
                        if (reader["Status"] != DBNull.Value)
                        {
                            try
                            {
                                objSample.Status = (ReSamplingStatus)(int.Parse(reader["Status"].ToString()));
                            }
                            catch
                            {
                                throw new Exception("Unable to Get Status.");
                            }
                        }
                        if (reader["DateTimeRequested"] != DBNull.Value)
                        {
                            try
                            {
                                objSample.DateTimeRequested = DateTime.Parse(reader["DateTimeRequested"].ToString());
                            }
                            catch
                            {
                                throw new Exception("Unable to Date requested.");
                            }
                        }
                        objSample.Remark     = reader["Remark"].ToString();
                        objSample.TrackingNo = reader["TransactionId"].ToString();
                    }
                    return(objSample);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (conn != null)
                {
                    if (conn.State == ConnectionState.Open)
                    {
                        conn.Close();
                    }
                }
            }
            return(null);
        }
예제 #10
0
        private static List <ReSamplingBLL> SearchHelper(string strSql)
        {
            List <ReSamplingBLL> 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 <ReSamplingBLL>();
                while (reader.Read())
                {
                    ReSamplingBLL obj = new ReSamplingBLL();
                    if (reader["Id"] != null)
                    {
                        obj.Id = new Guid(reader["Id"].ToString());
                    }
                    if (reader["Status"] != DBNull.Value)
                    {
                        try
                        {
                            obj.Status = (ReSamplingStatus)int.Parse(reader["Status"].ToString());
                        }
                        catch
                        {
                        }
                    }
                    if (reader["SampleCode"] != DBNull.Value)
                    {
                        try
                        {
                            obj.SampleCode = int.Parse(reader["SampleCode"].ToString());
                        }
                        catch
                        {
                        }
                    }

                    if (reader["DateTimeRequested"] != DBNull.Value)
                    {
                        try
                        {
                            obj.DateTimeRequested = DateTime.Parse(reader["DateTimeRequested"].ToString());
                        }
                        catch { }
                    }
                    if (reader["TransactionId"] != DBNull.Value)
                    {
                        try
                        {
                            obj.TrackingNo = reader["TransactionId"].ToString();
                        }
                        catch { }
                    }
                    list.Add(obj);
                }
                if (conn.State == ConnectionState.Open)
                {
                    conn.Close();
                }
                return(list);
            }
            else
            {
                if (conn.State == ConnectionState.Open)
                {
                    conn.Close();
                }
                return(null);
            }
        }
예제 #11
0
        protected void btnSearch_Click(object sender, EventArgs e)
        {
            string                      TrackingNo         = string.Empty;
            Nullable <int>              previousSampleCode = null;
            Nullable <DateTime>         from   = null;
            Nullable <DateTime>         to     = null;
            Nullable <ReSamplingStatus> status = null;

            #region inputvalidation
            if (this.txtTrackingNo.Text != "")
            {
                TrackingNo = this.txtTrackingNo.Text;
            }
            if (this.txtSamplingCode.Text != null)
            {
                try
                {
                    previousSampleCode = int.Parse(this.txtSamplingCode.Text);
                }
                catch
                {
                }
            }
            if (this.txtFrom.Text != null)
            {
                try
                {
                    from = DateTime.Parse(this.txtFrom.Text);
                }
                catch
                {
                }
            }
            if (this.txtTo.Text != null)
            {
                try
                {
                    to = DateTime.Parse(this.txtTo.Text);
                }
                catch
                {
                }
            }
            if (this.cboStatus.SelectedValue != null || this.cboStatus.SelectedValue != "")
            {
                try
                {
                    status = (ReSamplingStatus)(int.Parse(this.cboStatus.SelectedValue.ToString()));
                }
                catch
                {
                }
            }
            #endregion
            ReSamplingBLL        obj  = new ReSamplingBLL();
            List <ReSamplingBLL> list = new List <ReSamplingBLL>();
            try
            {
                list = obj.Search(TrackingNo, previousSampleCode, from, to, status);
                if (list != null)
                {
                    if (list.Count == 0)
                    {
                        this.lblmsg.Text = "No Records Found";
                        return;
                    }
                    else
                    {
                        this.gvDetail.DataSource = list;
                        this.gvDetail.DataBind();
                    }
                }
                else
                {
                    this.lblmsg.Text = "No Records Found";
                }
            }
            catch (Exception ex)
            {
                this.lblmsg.Text = ex.Message;
            }
        }