Example #1
0
    /// <summary>
    /// Storage Lot InfO Next button
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>

    protected void lbkNextLot_Click(object sender, EventArgs e)
    {
        try
        {
            if (Lots.getAllLotStatusByOrganizationIdAndLotNumber(UserOrganizationId, Conversion.ParseInt(hndfacilityId.Value), txtParkingLot.Text.Trim()) > 0)
            {
                lblErrorLot.Text     = "Storage Lot Already Exist!";
                lblErrorLot.Visible  = true;
                lblErrorLot.CssClass = "alert-danger custom-absolute-alert";
                ScriptManager.RegisterStartupScript(this, GetType(), "fadeOut", "fadeOut();", true);
                return;
            }



            lblErrorLane.Text  = string.Empty;
            lblErrorLot.Text   = string.Empty;
            lblErrorSpace.Text = string.Empty;



            int  id  = 0;
            Lots lot = new Lots();
            lot.LotNumber      = txtParkingLot.Text.Trim(); //Guid.NewGuid().ToString().Substring(0, 6);
            lot.Quantity       = 0;
            lot.OrganizationId = UserOrganizationId;        // Convert.ToInt32(ddlStakeholder.SelectedValue);
            lot.DateCreated    = DateTime.Now;
            lot.IsActive       = true;
            lot.SpaceId        = 0;
            lot.UserID         = LoginMemberId;          // currentUserInfo.UserId;
            lot.RoleID         = UserOrganizationRoleId; // currentUserInfo.RoleId;
            lot.IsCompleted    = true;


            BarCode br = new BarCode();
            br.DateCreated    = DateTime.Now.ToString();
            br.OrganizationID = UserOrganizationId;
            br.BarCodeNumber  = GenerateLotSerialNumber();
            // Guid g = Guid.NewGuid();
            string str = br.BarCodeNumber.ToString().Replace("-", "");
            if (br.GenerateLotBarCodeImage(str))
            {
                hdnLotBarCodeImageFileName.Value = str + ".gif";
                //imgLotBarcode.ImageUrl = String.Format("/images/temp/{0}.Gif", str);
                //imgLotBarcode.Visible = true;
            }
            if (System.IO.File.Exists(Server.MapPath(String.Format("/images/temp/{0}", hdnLotBarCodeImageFileName.Value))))
            {
                br.Image = System.IO.File.ReadAllBytes(Server.MapPath(String.Format("/images/temp/{0}", hdnLotBarCodeImageFileName.Value)));
            }
            lot.BarCodeId         = BarCode.Insert(br);
            lot.SubLot            = false;
            lot.Permanent         = true;
            lot.ProductCategoryId = CatId;
            string serialNumber;
            if (Request.QueryString["fid"] != null)
            {
                int facilityid = Convert.ToInt32(Request.QueryString["fid"]);



                serialNumber = Lots.insertLot(lot, out id, str, facilityid);
                LoadLots(1, facilityid);
                hidLotId.Value      = id.ToString();
                dvLotRecord.Visible = true;
                if (id > 0)
                {
                    lblErrorLot.Text     = "Storage Lot added successfully!";
                    lblErrorLot.Visible  = true;
                    lblErrorLot.CssClass = "alert-success custom-absolute-alert";
                    ScriptManager.RegisterStartupScript(this, GetType(), "fadeOut", "fadeOut();", true);
                    txtParkingLot.Text = string.Empty;
                }
            }
            else if (Request.QueryString["fids"] != null)
            {
                int facilityid = Convert.ToInt32(Request.QueryString["fids"]);



                serialNumber = Lots.insertLot(lot, out id, str, facilityid);
                LoadLots(1, facilityid);
                hidLotId.Value      = id.ToString();
                dvLotRecord.Visible = true;
                if (id > 0)
                {
                    lblErrorLot.Text     = "Storage Lot added successfully!";
                    lblErrorLot.CssClass = "alert-success custom-absolute-alert";
                    lblErrorLot.Visible  = true;
                    ScriptManager.RegisterStartupScript(this, GetType(), "fadeOut", "fadeOut();", true);
                    txtParkingLot.Text = string.Empty;
                }
            }
            else
            {
                serialNumber        = Lots.insertLot(lot, out id, str, 0);
                hidLotId.Value      = id.ToString();
                dvLotRecord.Visible = true;
                if (id > 0)
                {
                    lblErrorLot.Text = "Storage Lot added successfully!";
                    ScriptManager.RegisterStartupScript(this, GetType(), "fadeOut", "fadeOut();", true);

                    lblErrorLot.CssClass = "alert-success custom-absolute-alert";
                    lblErrorLot.Visible  = true;
                    txtParkingLot.Text   = string.Empty;
                }
                LoadLots(1);
            }
            // Response.Redirect("lots");
            //dvSpaceRecord.Visible = true;
        }
        catch (Exception ex)
        {
            new SqlLog().InsertSqlLog(0, "addInventory.lnkLotSave_Click", ex);
        }
    }
Example #2
0
    /// <summary>
    /// End GridView Space Info Funcations
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>



    /////star of Stroage lots Info Grids Funcations////////////////


    protected void gvLot_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName == "AddMore")
        {
            LinkButton lnkbtnAddMoreSetting = gvLot.FooterRow.FindControl("lnkbtnAddMore") as LinkButton;
            LinkButton lnkbtnAddSetting     = gvLot.FooterRow.FindControl("lnkbtnAddSetting") as LinkButton;
            LinkButton lnkbtnCancelSetting  = gvLot.FooterRow.FindControl("lnkbtnCancelSetting") as LinkButton;


            lnkbtnAddSetting.Visible     = true;
            lnkbtnAddMoreSetting.Visible = false;
            lnkbtnCancelSetting.Visible  = true;

            TextBox txtLotFooter = gvLot.FooterRow.FindControl("txtLotfooter") as TextBox;
            //TextBox txtSpace = gvSetting.FooterRow.FindControl("txtSpaces") as TextBox;
            txtLotFooter.Visible = true;
        }

        if (e.CommandName == "AddLotSpace")
        {
            lblErrorLane.Text  = String.Empty;
            lblErrorLot.Text   = String.Empty;
            lblErrorSpace.Text = String.Empty;


            pnlLot.Visible   = false;
            pnlSpace.Visible = true;
            hidLotId.Value   = Convert.ToString(e.CommandArgument);

            GridViewRow gvr      = (GridViewRow)(((LinkButton)e.CommandSource).NamingContainer);
            int         RemoveAt = gvr.RowIndex;
            Label       lbl      = (Label)gvLot.Rows[RemoveAt].FindControl("lbllotnumber");
            lblLotNumberSpace.Text   = lbl.Text;
            lblFacilityForSpace.Text = lblfacilityname.Text;
            LoadRows(1);
        }


        if (e.CommandName == "Insert")
        {
            try
            {
                TextBox txtParkingLot = (TextBox)((GridView)sender).FooterRow.FindControl("txtLotfooter");

                int  id  = 0;
                Lots lot = new Lots();
                lot.LotNumber      = txtParkingLot.Text.Trim(); //Guid.NewGuid().ToString().Substring(0, 6);
                lot.Quantity       = 0;
                lot.OrganizationId = UserOrganizationId;        // Convert.ToInt32(ddlStakeholder.SelectedValue);
                lot.DateCreated    = DateTime.Now;
                lot.IsActive       = true;
                lot.SpaceId        = 0;
                lot.UserID         = LoginMemberId;          // currentUserInfo.UserId;
                lot.RoleID         = UserOrganizationRoleId; // currentUserInfo.RoleId;
                lot.IsCompleted    = true;


                BarCode br = new BarCode();
                br.DateCreated    = DateTime.Now.ToString();
                br.OrganizationID = UserOrganizationId;
                br.BarCodeNumber  = GenerateLotSerialNumber();
                Guid   g   = Guid.NewGuid();
                string str = g.ToString().Replace("-", "");
                if (br.GenerateLotBarCodeImage(str))
                {
                    hdnLotBarCodeImageFileName.Value = str + ".gif";
                    //imgLotBarcode.ImageUrl = String.Format("/images/temp/{0}.Gif", str);
                    //imgLotBarcode.Visible = true;
                }
                if (System.IO.File.Exists(Server.MapPath(String.Format("/images/temp/{0}", hdnLotBarCodeImageFileName.Value))))
                {
                    br.Image = System.IO.File.ReadAllBytes(Server.MapPath(String.Format("/images/temp/{0}", hdnLotBarCodeImageFileName.Value)));
                }
                lot.BarCodeId = BarCode.Insert(br);

                lot.SubLot    = false;
                lot.Permanent = true;
                string serialNumber = Lots.insertLot(lot, out id, str);
                hidLotId.Value = id.ToString();
                //lbkSaveLot.Visible = false;
                dvLotRecord.Visible = true;
                LoadLots(1);
                //dvSpaceRecord.Visible = true;
            }
            catch (Exception ex)
            {
                new SqlLog().InsertSqlLog(0, "addInventory.lnkLotSave_Click", ex);
            }
        }

        else if (e.CommandName == "Edit")
        {
            hidLotId.Value   = Convert.ToString(e.CommandArgument);
            lblErrorLot.Text = string.Empty;
        }

        else if (e.CommandName == "Delete")
        {
            int lotId = Convert.ToInt32(e.CommandArgument);
            if (!lothaveTire(lotId))
            {
                Lots.deleteLot(lotId);
                lblErrorLot.Text = string.Empty;
                LoadLots(1);
                lblErrorLane.Text  = string.Empty;
                lblErrorLot.Text   = string.Empty;
                lblErrorSpace.Text = string.Empty;
            }
        }
        else if (e.CommandName == "RowInfoPopUp")
        {
            LotRowControl.Visible = true;

            lblErrorLot.Text = String.Empty;
            //lblErrorSpace.Text = String.Empty;

            dvpopupfacilityinfo.Visible = true;
            //pnlLot.Visible = false;


            hidLotId.Value = Convert.ToString(e.CommandArgument);
            Lots objLots = new Lots(Conversion.ParseInt(hidLotId.Value));

            GridViewRow gvr      = (GridViewRow)(((LinkButton)e.CommandSource).NamingContainer);
            int         RemoveAt = gvr.RowIndex;
            HiddenField lbl      = (HiddenField)gvLot.Rows[RemoveAt].FindControl("hdGVLotNumber");
            hdnlotname.Value = lbl.Value;
            LotRowControl.loadFacilityandLotName(objLots.FacilityName, lbl.Value, hndfacilityId.Value);
            LotRowControl.loadLotRows(Convert.ToInt32(e.CommandArgument));
        }

        else if (e.CommandName == "Cancel")
        {
            gvLot.EditIndex = -1;
            LoadLots(1);
        }
    }