Example #1
0
 private void BindStackInformation()
 {
     if (ViewState["vwStackUnloaded"] == null)
     {
         StackUnloadedBLL obj = new StackUnloadedBLL();
         try
         {
             obj.UnloadingId = new Guid(Request.QueryString["Id"].ToString());
         }
         catch
         {
             this.lblMsg2.Text = "Unable to process the request";
             return;
         }
         List <StackUnloadedBLL> list = new List <StackUnloadedBLL>();
         list = obj.GetStackInformationByUnloadingId();
         if (list != null)
         {
             ViewState["vwStackUnloaded"]         = list;
             ViewState["vwStackUnloadedOriginal"] = list;
             this.gvStackUnloaded.DataSource      = list;
             this.gvStackUnloaded.DataBind();
         }
         else
         {
             this.lblMsg2.Text = "No Stack Information.";
         }
     }
     else
     {
         List <StackUnloadedBLL> list = new List <StackUnloadedBLL>();
         list = (List <StackUnloadedBLL>)ViewState["vwStackUnloaded"];
         int totBagCount = 0;
         foreach (StackUnloadedBLL su in list)
         {
             if (su.Status == StackUnloadedStatus.New)
             {
                 totBagCount = su.NumberOfbags;
             }
         }
         if (ViewState["totBagCount"] == null)
         {
             ViewState["totBagCount"] = totBagCount;
         }
         this.gvStackUnloaded.DataSource = list;
         this.gvStackUnloaded.DataBind();
     }
 }
Example #2
0
        public static bool InsertStackUnloaded(StackUnloadedBLL obj, SqlTransaction tran)
        {
            int    affectedrow = 0;
            string strSql      = "spInsertStackUnloaded";

            SqlParameter[] arPar = new SqlParameter[7];
            try
            {
                arPar[0]       = new SqlParameter("@UnloadingId", SqlDbType.UniqueIdentifier);
                arPar[0].Value = obj.UnloadingId;

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

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

                arPar[3]       = new SqlParameter("@Status", SqlDbType.Int);
                arPar[3].Value = (int)StackUnloadedStatus.New;

                arPar[4]       = new SqlParameter("@UnloadedBy", SqlDbType.UniqueIdentifier);
                arPar[4].Value = obj.UserId;

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

                arPar[6]       = new SqlParameter("@CreatedBy", SqlDbType.UniqueIdentifier);
                arPar[6].Value = UserBLL.GetCurrentUser();

                affectedrow = SqlHelper.ExecuteNonQuery(tran, strSql, arPar);
                if (affectedrow == 1)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception ex)
            {
                tran.Rollback();
                throw ex;
            }
        }
Example #3
0
        protected void gvStackUnloaded_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                StackUnloadedBLL obj = (StackUnloadedBLL)e.Row.DataItem;

                if (this.gvStackUnloaded.EditIndex == -1)
                {
                    Label lblInv    = (Label)e.Row.FindControl("lblInvetoryCont");
                    Label lblStaclg = (Label)e.Row.FindControl("lblStackNo");
                    lblInv.Text    = UserRightBLL.GetUserNameByUserId(obj.UserId);
                    lblStaclg.Text = obj.StackNo;
                }
                else
                {
                    //Label lblEditstat = (Label)e.Row.FindControl("lblEditstatus");
                    //DropDownList cboInv = (DropDownList)e.Row.FindControl("cboStackUnloadedStatus");
                    //cboInv.SelectedValue = lblEditstat.Text;
                }
            }
        }
Example #4
0
        public static bool UpdateStackUnloaded(StackUnloadedBLL obj, SqlTransaction tran)
        {
            int    affectedrow = 0;
            string strSql      = "spUpdateStack";

            SqlParameter[] arPar = new SqlParameter[5];
            try
            {
                arPar[0]       = new SqlParameter("@id", SqlDbType.UniqueIdentifier);
                arPar[0].Value = obj.Id;

                arPar[1]       = new SqlParameter("@NumberOfBags", SqlDbType.Int);
                arPar[1].Value = obj.NumberOfbags;

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

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

                arPar[4]       = new SqlParameter("@LastModifiedBy", SqlDbType.UniqueIdentifier);
                arPar[4].Value = UserBLL.GetCurrentUser();

                affectedrow = SqlHelper.ExecuteNonQuery(tran, strSql, arPar);
                if (affectedrow == 1)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #5
0
        protected void gvStackUnloaded_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            this.lblMsg2.Text = "";
            this.lblmsg.Text  = "";
            StackUnloadedBLL obj           = new StackUnloadedBLL();
            GridViewRow      row           = this.gvStackUnloaded.Rows[e.RowIndex];
            Label            lblId         = row.FindControl("lblId") as Label;
            TextBox          remark        = row.FindControl("txtStackRemark") as TextBox;
            Label            lblEditstatus = row.FindControl("lblEditstatus") as Label;
            Label            lblNoBag      = row.FindControl("lblNoBag") as Label;
            int CurrBag = 0;

            if ((int.TryParse(lblNoBag.Text.ToString(), out CurrBag)) != true)
            {
                throw new Exception("Invalid No. Bags");
            }


            DropDownList cg = row.FindControl("cboStackUnloadedStatus") as DropDownList;

            if (cg.SelectedValue.ToString() == "3")
            {
                if (remark != null)
                {
                    if (remark.Text == "" || remark.Text == string.Empty)
                    {
                        this.lblMsg2.Text = "Please provide Remark.";
                        return;
                    }
                    else
                    {
                        obj.Remark = remark.Text;
                    }
                }
            }
            List <StackUnloadedBLL> list = new List <StackUnloadedBLL>();

            if (ViewState["vwStackUnloaded"] != null)
            {
                list = (List <StackUnloadedBLL>)ViewState["vwStackUnloaded"];

                ViewState["vwStackUnloaded"] = list;
                int totBagCount = 0;
                if (ViewState["totBagCount"] != null)
                {
                    totBagCount = int.Parse(ViewState["totBagCount"].ToString());
                    if (lblEditstatus.Text == "New" && cg.SelectedValue.ToString().Trim() == "Cancelled")
                    {
                        totBagCount = totBagCount - CurrBag;
                    }
                    else if (lblEditstatus.Text == "Cancelled" && cg.SelectedValue.ToString().Trim() == "New")
                    {
                        int xtotalNumberofBags;
                        int xtotBagCount = 0;
                        int xbag         = 0;
                        if ((int.TryParse(this.txtNumberOfBags.Text, out xtotalNumberofBags)) == false)
                        {
                            this.lblmsg.Text = "Please enter Total Number of Bags";
                            return;
                        }
                        if (ViewState["totBagCount"] != null)
                        {
                            if ((int.TryParse(ViewState["totBagCount"].ToString(), out xtotBagCount)) != true)
                            {
                                this.lblmsg.Text = "Invalid Total Number of Bags per Stack.";
                                return;
                            }
                        }
                        else
                        {
                            totBagCount = 0;
                        }

                        if ((int.TryParse(lblNoBag.Text, out xbag) != true))
                        {
                            this.lblmsg.Text = "Invalid Stack Number of Bags.";
                            return;
                        }

                        if (xtotalNumberofBags > (totBagCount + CurrBag))
                        {
                            totBagCount = totBagCount + CurrBag;
                        }
                        else
                        {
                            this.lblMsg2.Text = "The Sum of the bags unloaded per stack exceeds the Total count";
                            return;
                        }
                        foreach (StackUnloadedBLL i in list)
                        {
                            if (i.Id.ToString().ToLower() == lblId.Text.ToLower())
                            {
                                if (cg.SelectedValue.ToString().Trim() == "New")
                                {
                                    i.Status = StackUnloadedStatus.New;
                                }
                                else if (cg.SelectedValue.ToString().Trim() == "Cancelled")
                                {
                                    i.Status = StackUnloadedStatus.Cancelled;
                                }
                                i.Remark = remark.Text;
                                break;
                            }
                        }
                    }
                    List <StackUnloadedBLL> listOriginal = new List <StackUnloadedBLL>();
                    bool isSavedtoDb = false;
                    listOriginal = (List <StackUnloadedBLL>)ViewState["vwStackUnloadedOriginal"];
                    foreach (StackUnloadedBLL o in listOriginal)
                    {
                        if (o.Id == new Guid(lblId.Text))
                        {
                            isSavedtoDb = true;
                        }
                        if (isSavedtoDb == true)
                        {
                            break;
                        }
                    }
                    if (isSavedtoDb == false)
                    {
                        int x = 0;
                        foreach (StackUnloadedBLL i in list)
                        {
                            if (i.Id == new Guid(lblId.Text))
                            {
                                break;
                            }
                            x++;
                        }
                        list.RemoveAt(x);
                        ViewState["vwStackUnloaded"] = list;
                    }
                    else
                    {
                        int x = 0;
                        foreach (StackUnloadedBLL i in list)
                        {
                            if (i.Id == new Guid(lblId.Text))
                            {
                                break;
                            }
                            x++;
                        }
                        if (cg.SelectedValue.ToString() == "New")
                        {
                            list[x].Status = StackUnloadedStatus.New;
                        }
                        else if (cg.SelectedValue.ToString() == "Cancelled")
                        {
                            list[x].Status = StackUnloadedStatus.Cancelled;
                        }
                        // call the update Method to change the status.

                        ViewState["vwStackUnloaded"] = list;
                    }

                    ViewState["totBagCount"] = totBagCount;
                }


                this.gvStackUnloaded.EditIndex = -1;
                BindStackInformation();
            }
        }
Example #6
0
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            this.lblMsg2.Text = "";
            this.lblmsg.Text  = "";
            int totalNumberofBags;
            int totBagCount = 0;

            int bag = 0;

            if ((int.TryParse(this.txtNumberOfBags.Text, out totalNumberofBags)) == false)
            {
                this.lblmsg.Text = "Please enter Total Number of Bags";
                return;
            }
            if (ViewState["totBagCount"] != null)
            {
                if ((int.TryParse(ViewState["totBagCount"].ToString(), out totBagCount)) != true)
                {
                    this.lblmsg.Text = "Invalid Total Number of Bags per Stack.";
                    return;
                }
            }
            else
            {
                totBagCount = 0;
            }

            if ((int.TryParse(this.txtStackNoBags.Text, out bag)) != true)
            {
                this.lblMsg2.Text = "Please Enter Number of bags.";
                this.txtStackNoBags.Focus();
                return;
            }

            if (totalNumberofBags < totBagCount + bag)
            {
                this.lblMsg2.Text = "The sum of the number per stack exceeds the total number of bags.";
                this.txtStackNoBags.Focus();
                return;
            }


            StackUnloadedBLL obj         = new StackUnloadedBLL();
            Nullable <Guid>  unloadingId = null;

            if (DataValidationBLL.isGUID(this.hfUnloadingId.Value.ToString(), out unloadingId) == true)
            {
                obj.UnloadingId = (Guid)unloadingId;
            }
            else
            {
                this.lblMsg2.Text = "Please Select Stack";
                this.cboStackNo.Focus();
                return;
            }



            try
            {
                obj.StackId = new Guid(this.cboStackNo.SelectedValue.ToString());
                obj.StackNo = this.cboStackNo.SelectedItem.Text;
            }
            catch
            {
                this.lblMsg2.Text = "Please Select Stack";
                this.cboStackNo.Focus();
                return;
            }
            Nullable <Guid> user = null;

            if (DataValidationBLL.isGUID(this.cboUnloadedBy.SelectedValue.ToString(), out user) == true)
            {
                obj.UserId = (Guid)user;
            }
            else
            {
                this.lblMsg2.Text = "Please Select Inventory controller";
                this.cboUnloadedBy.Focus();
                return;
            }
            obj.NumberOfbags = (int)bag;
            obj.Status       = StackUnloadedStatus.New;
            obj.Remark       = this.txtRemark.Text;
            List <StackUnloadedBLL> list = new List <StackUnloadedBLL>();

            list = (List <StackUnloadedBLL>)ViewState["vwStackUnloaded"];
            list.Add(obj);
            ViewState["vwStackUnloaded"] = list;
            ViewState["totBagCount"]     = totBagCount + bag;
            BindStackInformation();
        }
Example #7
0
        public static List <StackUnloadedBLL> GetStackUnloadedByUnloadingId(Guid UnloadingId)
        {
            string strSql = "spGetStackInformationByUnloadingId";
            List <StackUnloadedBLL> list;
            SqlDataReader           reader;

            SqlParameter[] arPar = new SqlParameter[1];

            arPar[0]       = new SqlParameter("@UnloadingId", SqlDbType.UniqueIdentifier);
            arPar[0].Value = UnloadingId;

            try
            {
                reader = SqlHelper.ExecuteReader(Connection.getConnection(), CommandType.StoredProcedure, strSql, arPar);
                if (reader.HasRows)
                {
                    list = new List <StackUnloadedBLL>();
                    while (reader.Read())
                    {
                        int inserttolist     = 0;
                        StackUnloadedBLL obj = new StackUnloadedBLL();
                        Nullable <Guid>  Id  = null;
                        if (DataValidationBLL.isGUID(reader["Id"].ToString(), out Id) == true)
                        {
                            obj.Id = (Guid)Id;
                        }
                        else
                        {
                            inserttolist = -1;
                        }
                        Nullable <Guid> StackId = null;
                        if (DataValidationBLL.isGUID(reader["StackId"].ToString(), out StackId) == true)
                        {
                            obj.StackId = (Guid)StackId;
                        }
                        else
                        {
                            inserttolist = -1;
                        }
                        //Inventory Controller.
                        Nullable <Guid> UnloadedBy = null;
                        if (DataValidationBLL.isGUID(reader["UnloadedBy"].ToString(), out UnloadedBy) == true)
                        {
                            obj.UserId = (Guid)UnloadedBy;
                        }
                        //Number of Bags
                        Nullable <Int32> noBags = null;
                        if (DataValidationBLL.isInteger(reader["NumberOfBags"].ToString(), out noBags) == true)
                        {
                            obj.NumberOfbags = (int)noBags;
                        }
                        Nullable <Int32> status = null;
                        if (DataValidationBLL.isInteger(reader["Status"].ToString(), out status) == true)
                        {
                            obj.Status = (StackUnloadedStatus)(int)status;
                        }

                        obj.Remark  = reader["Remark"].ToString();
                        obj.StackNo = reader["StackNumber"].ToString();
                        Nullable <Guid> ShedId = null;
                        if (DataValidationBLL.isGUID(reader["ShedId"].ToString(), out ShedId) == true)
                        {
                            obj.ShedId = (Guid)ShedId;
                        }
                        if (inserttolist != -1)
                        {
                            list.Add(obj);
                        }
                    }
                    return(list);
                }
                else
                {
                    return(null);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #8
0
        public static StackUnloadedBLL GetStackUnloadedById(Guid Id)
        {
            string           strSql = "spGetStackUnloadedById";
            StackUnloadedBLL obj    = null;
            SqlDataReader    reader;

            SqlParameter[] arPar = new SqlParameter[1];

            arPar[0]       = new SqlParameter("@Id", SqlDbType.UniqueIdentifier);
            arPar[0].Value = Id;
            SqlConnection conn = null;

            try
            {
                conn   = Connection.getConnection();
                reader = SqlHelper.ExecuteReader(conn, CommandType.StoredProcedure, strSql, arPar);
                if (reader.HasRows)
                {
                    obj = new StackUnloadedBLL();
                    reader.Read();



                    if (reader["Id"] != DBNull.Value)
                    {
                        obj.Id = new Guid(reader["Id"].ToString());
                    }



                    if (reader["StackId"] != DBNull.Value)
                    {
                        obj.StackId = new Guid(reader["StackId"].ToString());
                    }

                    //Inventory Controller.
                    Nullable <Guid> UnloadedBy = null;
                    if (DataValidationBLL.isGUID(reader["UnloadedBy"].ToString(), out UnloadedBy) == true)
                    {
                        obj.UserId = (Guid)UnloadedBy;
                    }
                    //Number of Bags
                    Nullable <Int32> noBags = null;
                    if (DataValidationBLL.isInteger(reader["NumberOfBags"].ToString(), out noBags) == true)
                    {
                        obj.NumberOfbags = (int)noBags;
                    }
                    Nullable <Int32> status = null;
                    if (DataValidationBLL.isInteger(reader["Status"].ToString(), out status) == true)
                    {
                        obj.Status = (StackUnloadedStatus)(int)status;
                    }

                    obj.Remark  = reader["Remark"].ToString();
                    obj.StackNo = reader["StackNumber"].ToString();
                    Nullable <Guid> ShedId = null;
                    if (DataValidationBLL.isGUID(reader["ShedId"].ToString(), out ShedId) == true)
                    {
                        obj.ShedId = (Guid)ShedId;
                    }
                }
                else
                {
                    obj = null;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (conn != null)
                {
                    if (conn.State == ConnectionState.Open)
                    {
                        conn.Close();
                    }
                }
            }
            return(obj);
        }
Example #9
0
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            this.lblMsg2.Text = "";
            this.lblmsg.Text  = "";
            int totalNoBags      = int.Parse(this.txtNumberOfBags.Text);
            int totalNoBagsSoFar = int.Parse(ViewState["TotalBagsSoFar"].ToString()) + int.Parse(this.txtStackNoBags.Text);

            if (totalNoBags < totalNoBagsSoFar)
            {
                this.lblmsg.Text = "The sum of Unloaded bags exceeded Total Number of bags.";
                return;
            }
            List <StackUnloadedBLL> list = new List <StackUnloadedBLL>();

            list = (List <StackUnloadedBLL>)ViewState["StackUnloaded"];
            if (list == null)
            {
                list = new List <StackUnloadedBLL>();
            }
            StackUnloadedBLL obj = new StackUnloadedBLL();

            obj.Id = Guid.NewGuid();
            Nullable <Guid> stackId = null;

            if (DataValidationBLL.isGUID(this.cboStackNo.SelectedValue.ToString(), out stackId) == false)
            {
                this.lblmsg.Text = "please select Stack No.";
                bindGrid();
                return;
            }
            else
            {
                obj.StackId = (Guid)stackId;
            }
            //check if a stack is already there.
            foreach (StackUnloadedBLL i in list)
            {
                if (obj.StackId == i.StackId)
                {
                    this.lblMsg2.Text = "The Stack has already been used.";
                    bindGrid();
                    return;
                }
            }



            Nullable <Int32> noBags = null;

            if (DataValidationBLL.isInteger(this.txtStackNoBags.Text, out noBags) == false)
            {
                this.lblmsg.Text = "please enter no. bags.";
                this.txtStackNoBags.Focus();
                bindGrid();
                return;
            }
            else
            {
                obj.NumberOfbags = (int)noBags;
            }
            Nullable <Guid> user = null;

            if (DataValidationBLL.isGUID(this.cboUnloadedBy.SelectedValue.ToString(), out user) == false)
            {
                this.lblmsg.Text = "please select inventory Controller.";
                bindGrid();
                return;
            }
            else
            {
                obj.UserId = (Guid)user;
            }
            obj.Status    = StackUnloadedStatus.New;
            obj.CreatedBy = UserBLL.GetCurrentUser();
            obj.StackNo   = this.cboStackNo.SelectedItem.ToString();
            obj.InventoryControllerName = this.cboUnloadedBy.SelectedItem.ToString();
            obj.Remark = this.txtRemark.Text;

            list.Add(obj);
            ViewState["StackUnloaded"]  = list;
            ViewState["TotalBagsSoFar"] = totalNoBagsSoFar;
            bindGrid();
            stackBagsClear();
        }