protected void Page_Load(object sender, EventArgs e)
    {
         EmployeeLogic el = new EmployeeLogic();
        Employee e2 = el.SelectByID(Convert.ToInt32(Session["EmployeeID"]));
        if (!(e2.Designation.Equals("HR MANAGER") || e2.Designation.Equals("HR EMPLOYEE")))
        {
            OrderLogic ol = new OrderLogic();
            Order o1=ol.SelectByID(Convert.ToInt32(Request.QueryString["id"]));;

            if (o1 != null)
            {
                ProductLogic pl = new ProductLogic();
                Product p1 = pl.SelectByProductID(o1.ProductID);
                Label1.Text = p1.Name;
                Label2.Text = o1.QuotationID.ToString();
                Label3.Text = o1.Quantity.ToString();
                Label4.Text = o1.Rate.ToString();
                Label5.Text = o1.PONumber.ToString();
                Label6.Text = o1.PODate.ToString("dd/MM/yyyy");
                Label7.Text = o1.CreateDate.ToString("dd/MM/yyyy");
                Label8.Text = o1.Status;
                Label9.Text = o1.StatusRemarks;
                Label10.Text = o1.DeliveryAddress;
                Label11.Text = o1.DeliveryDate.ToString("dd/MM/yyyy");
                String oo = o1.AttachPO;
                lnkImage1.Text = oo.Substring(25);
                lnkImage1.NavigateUrl = oo;
            
            }
        }
        else
        {
            Response.Redirect("Access.aspx");
        }      
     }
    protected void Page_Load(object sender, EventArgs e)
    {
        DataTable dt3 = new ProductLogic().SelectBestProduct();
        OrderNumber.Text = dt3.Rows[0]["Total"].ToString() + " Orders";
        string dp1 = dt3.Rows[0]["DesignFiles"].ToString();
        String[] arr1 = dp1.Split(new String[] { "#,#" }, StringSplitOptions.RemoveEmptyEntries);
        topProimg.Src = arr1[arr1.Length - 1];

        ProName.Text = dt3.Rows[0]["Name"].ToString();
    }
    protected void Page_Load(object sender, EventArgs e)
    {   
        EmployeeLogic el = new EmployeeLogic();
        Employee e2 = el.SelectByID(Convert.ToInt32(Session["EmployeeID"]));
       
            if (!IsPostBack)
            {
                if (e2.Designation.Equals("MANAGING DIRECTOR") || e2.Designation.Equals("CHAIRMAN") || e2.Designation.Equals("COMERCIAL MANAGER") || e2.Designation.Equals("COMERCIAL EMPLOYEE") || e2.Designation.Equals("MARKETING MANAGER") || e2.Designation.Equals("MARKETING EMPLOYEE") || e2.Designation.Equals("PRODUCTION MANAGER") || e2.Designation.Equals("PRODUCTION EMPLOYEE"))
                {
                QuotationLogic QL = new QuotationLogic();
                DataTable dt = QL.SelectAllJoined();
                Repeater1.DataSource = dt;
                Repeater1.DataBind();
                if (dt.Rows.Count == 0)
                {
                    Table1.Visible = false;
                    Label1.Visible = true;
                }
                else
                {
                    Table1.Visible = true;
                    Label1.Visible = false;
                }

                CustomerLogic cl = new CustomerLogic();
                DataTable dt1 = cl.SelectAll();
                dt1.Rows.Add(0, "All Customer", null, null, null, null, null, null, null, null, null);
                dt1.DefaultView.Sort = "CustomerID";
                DropDownList1.DataSource = dt1;
                DropDownList1.DataTextField = "Name";
                DropDownList1.DataValueField = "CustomerID";
                DropDownList1.DataBind();
                DropDownList1.SelectedItem.Text = "All Customer";

                ProductLogic pl = new ProductLogic();
                DataTable dt2 = pl.SelectAll();
                dt2.Rows.Add(0, "All Product", null, null, null, null, null, null, null, null);
                dt2.DefaultView.Sort = "ProductID";
                DropDownList2.DataSource = dt2;
                DropDownList2.DataTextField = "Name";
                DropDownList2.DataValueField = "ProductID";
                DropDownList2.DataBind();
                DropDownList2.SelectedItem.Text = "All Product";
            }
                else
                {
                    Response.Redirect("Access.aspx");
                }
        }
        

    }
 protected void Button1_Click(object sender, EventArgs e)
 {
     ProductLogic pl = new ProductLogic();
     DataTable dt = pl.Search(TextBox1.Text, DropDownList1.SelectedItem.Text, Convert.ToInt32(DropDownList2.SelectedItem.Value));
     Repeater1.DataSource = dt;
     Repeater1.DataBind();
     if (dt.Rows.Count == 0)
     {
         Table1.Visible = false;
         Label1.Visible = true;
     }
     else
     {
         Table1.Visible = true;
         Label1.Visible = false;
     }
 }
    protected void Page_Load(object sender, EventArgs e)
    {
         EmployeeLogic el = new EmployeeLogic();
        Employee e2 = el.SelectByID(Convert.ToInt32(Session["EmployeeID"]));
       
            if (!IsPostBack)
            {
                if (!(e2.Designation.Equals("STOCK MANAGER") || e2.Designation.Equals("STOCK EMPLOYEE") || e2.Designation.Equals("ACCOUNTATANT") || e2.Designation.Equals("HR MANAGER") || e2.Designation.Equals("HR EMPLOYEE")))
                {
                ProductLogic PL = new ProductLogic();

                DataTable dt = PL.SelectAllJoined();

                Repeater1.DataSource = dt;
                Repeater1.DataBind();
                if (dt.Rows.Count == 0)
                {
                    Table1.Visible = false;
                    Label1.Visible = true;
                }
                else
                {
                    Table1.Visible = true;
                    Label1.Visible = false;
                }

                CustomerLogic cl = new CustomerLogic();
                DataTable dt1 = cl.SelectAll();
                dt1.Rows.Add(0, "All Customers", null, null, null, null, null, null, null, null, null);
                dt1.DefaultView.Sort = "CustomerID";
                DropDownList2.DataSource = dt1;
                DropDownList2.DataTextField = "Name";
                DropDownList2.DataValueField = "CustomerID";
                DropDownList2.DataBind();
                //DropDownList2.SelectedValue = "All Customers";
            }
                else
                {
                    Response.Redirect("Access.aspx");
                }
        }
       
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        EmployeeLogic el = new EmployeeLogic();
        Employee e2 = el.SelectByID(Convert.ToInt32(Session["EmployeeID"]));
        if (e2.Designation.Equals("MANAGING DIRECTOR") || e2.Designation.Equals("CHAIRMAN") || e2.Designation.Equals("COMERCIAL MANAGER") || e2.Designation.Equals("COMERCIAL EMPLOYEE"))
        {
            if (!IsPostBack)
            {
                ProductLogic pl = new ProductLogic();
                DropDownList1.DataSource = pl.SelectAll();
                DropDownList1.DataTextField = "Name";
                DropDownList1.DataValueField = "ProductID";
                DropDownList1.DataBind();
                QuotationLogic ql = new QuotationLogic();
                Quotation q1 = ql.SelectByID(Convert.ToInt32(Request.QueryString["id"]));

                if (q1.QuotationID > 0)
                {
                    Product p1 = pl.SelectByProductID(q1.ProductID);
                    DropDownList1.SelectedItem.Value = p1.ProductID.ToString();
                    TextBox1.Text = q1.MOQ.ToString();
                    TextBox2.Text = q1.Rate.ToString();
                    TextBox3.Text = q1.CreateDate.ToString("dd/MM/yyyy");
                    TextBox4.Text = q1.Status;
                    TextBox5.Text = q1.Remarks;
                    TextBox6.Text = q1.TermsConditions;

                }
                else
                {
                    TextBox3.Text = DateTime.Now.ToString("dd/MM/yyyy");
                }
            }
        }
        else
        {
            Response.Redirect("Access.aspx");
        }
       
      
    }
    protected void LinkButton1_Command(object sender, CommandEventArgs e)
    {
         EmployeeLogic el = new EmployeeLogic();
        Employee e2 = el.SelectByID(Convert.ToInt32(Session["EmployeeID"]));
        if (!(e2.Designation.Equals("STOCK MANAGER") || e2.Designation.Equals("STOCK EMPLOYEE") || e2.Designation.Equals("EMPLOYEE") || e2.Designation.Equals("ACCOUNTATANT") || e2.Designation.Equals("HR MANAGER") || e2.Designation.Equals("HR EMPLOYEE")))
        {
            ProductLogic pl = new ProductLogic();
            Product p1 = pl.SelectByProductID(Convert.ToInt32(e.CommandArgument));
            if (p1 != null)
            {
                int i = pl.Delete(p1.ProductID);

                Response.Redirect("ProdList.aspx");

            }
        }
        else
        {
            Response.Redirect("Access.aspx");
        }

    }
    protected void Repeater1_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
        EmployeeLogic el = new EmployeeLogic();
        Employee e2 = el.SelectByID(Convert.ToInt32(Session["EmployeeID"]));
        if (!(e2.Designation.Equals("STOCK MANAGER") || e2.Designation.Equals("STOCK EMPLOYEE") || e2.Designation.Equals("ACCOUNTATANT") || e2.Designation.Equals("EMPLOYEE") || e2.Designation.Equals("HR MANAGER") || e2.Designation.Equals("HR EMPLOYEE")))
        {
            if(e.CommandName.Equals("Product Designed")){
                ProductLogic pl = new ProductLogic();
                Product p1 = pl.SelectByProductID(Convert.ToInt32(e.CommandArgument));
                p1.Status = "Product Designed";
                pl.Update(p1);
                DataTable dt = pl.SelectAllJoined();

                Repeater1.DataSource = dt;
                Repeater1.DataBind();
                if (dt.Rows.Count == 0)
                {
                    Table1.Visible = false;
                    Label1.Visible = true;
                }
                else
                {
                    Table1.Visible = true;
                    Label1.Visible = false;
                }
                TransitionLogic tl = new TransitionLogic();
                Transition t1 = new Transition();
                t1.KeyID = p1.ProductID;
                t1.KeyType = "Prod";
                t1.TranDate = DateTime.Now;
                t1.NewStatus = "Product Designed";
                t1.Remarks = ((TextBox)e.Item.FindControl("TextBox2")).Text;
                tl.Insert(t1);
            }else if(e.CommandName.Equals("Product Sent for client design approval")){
                ProductLogic pl = new ProductLogic();
                Product p1 = pl.SelectByProductID(Convert.ToInt32(e.CommandArgument));
                p1.Status = "Product Sent for client design approval";
                pl.Update(p1);
                DataTable dt = pl.SelectAllJoined();

                Repeater1.DataSource = dt;
                Repeater1.DataBind();
                if (dt.Rows.Count == 0)
                {
                    Table1.Visible = false;
                    Label1.Visible = true;
                }
                else
                {
                    Table1.Visible = true;
                    Label1.Visible = false;
                }
                TransitionLogic tl = new TransitionLogic();
                Transition t1 = new Transition();
                t1.KeyID = p1.ProductID;
                t1.KeyType = "Prod";
                t1.TranDate = DateTime.Now;
                t1.NewStatus = "Product Sent for client design approval";
                t1.Remarks = ((TextBox)e.Item.FindControl("TextBox2")).Text;
                tl.Insert(t1);
            }else if(e.CommandName.Equals("Design approved by client")){
                ProductLogic pl = new ProductLogic();
                Product p1 = pl.SelectByProductID(Convert.ToInt32(e.CommandArgument));
                p1.Status = "Design approved by client";
                pl.Update(p1);
                DataTable dt = pl.SelectAllJoined();

                Repeater1.DataSource = dt;
                Repeater1.DataBind();
                if (dt.Rows.Count == 0)
                {
                    Table1.Visible = false;
                    Label1.Visible = true;
                }
                else
                {
                    Table1.Visible = true;
                    Label1.Visible = false;
                }
                TransitionLogic tl = new TransitionLogic();
                Transition t1 = new Transition();
                t1.KeyID = p1.ProductID;
                t1.KeyType = "Prod";
                t1.TranDate = DateTime.Now;
                t1.NewStatus = "Design approved by client";
                t1.Remarks = ((TextBox)e.Item.FindControl("TextBox2")).Text;
                tl.Insert(t1);
            }else if(e.CommandName.Equals("Trial product prepared")){
                ProductLogic pl = new ProductLogic();
                Product p1 = pl.SelectByProductID(Convert.ToInt32(e.CommandArgument));
                p1.Status = "Trial product prepared";
                pl.Update(p1);
                DataTable dt = pl.SelectAllJoined();

                Repeater1.DataSource = dt;
                Repeater1.DataBind();
                if (dt.Rows.Count == 0)
                {
                    Table1.Visible = false;
                    Label1.Visible = true;
                }
                else
                {
                    Table1.Visible = true;
                    Label1.Visible = false;
                }
                TransitionLogic tl = new TransitionLogic();
                Transition t1 = new Transition();
                t1.KeyID = p1.ProductID;
                t1.KeyType = "Prod";
                t1.TranDate = DateTime.Now;
                t1.NewStatus = "Trial product prepared";
                t1.Remarks = ((TextBox)e.Item.FindControl("TextBox2")).Text;
                tl.Insert(t1);
            }else if(e.CommandName.Equals("Trial product sent for client approval")){
                ProductLogic pl = new ProductLogic();
                Product p1 = pl.SelectByProductID(Convert.ToInt32(e.CommandArgument));
                p1.Status = "Trial product sent for client approval";
                pl.Update(p1);
                DataTable dt = pl.SelectAllJoined();

                Repeater1.DataSource = dt;
                Repeater1.DataBind();
                if (dt.Rows.Count == 0)
                {
                    Table1.Visible = false;
                    Label1.Visible = true;
                }
                else
                {
                    Table1.Visible = true;
                    Label1.Visible = false;
                }
                TransitionLogic tl = new TransitionLogic();
                Transition t1 = new Transition();
                t1.KeyID = p1.ProductID;
                t1.KeyType = "Prod";
                t1.TranDate = DateTime.Now;
                t1.NewStatus = "Trial product sent for client approval";
                t1.Remarks = ((TextBox)e.Item.FindControl("TextBox2")).Text;
                tl.Insert(t1);
            }else if(e.CommandName.Equals("Trial product approved by client")){
                ProductLogic pl = new ProductLogic();
                Product p1 = pl.SelectByProductID(Convert.ToInt32(e.CommandArgument));
                p1.Status = "Trial product approved by client";
                pl.Update(p1);
                DataTable dt = pl.SelectAllJoined();

                Repeater1.DataSource = dt;
                Repeater1.DataBind();
                if (dt.Rows.Count == 0)
                {
                    Table1.Visible = false;
                    Label1.Visible = true;
                }
                else
                {
                    Table1.Visible = true;
                    Label1.Visible = false;
                }
                TransitionLogic tl = new TransitionLogic();
                Transition t1 = new Transition();
                t1.KeyID = p1.ProductID;
                t1.KeyType = "Prod";
                t1.TranDate = DateTime.Now;
                t1.NewStatus = "Trial product approved by client";
                t1.Remarks = ((TextBox)e.Item.FindControl("TextBox2")).Text;
                tl.Insert(t1);
            }else if(e.CommandName.Equals("product approved")){
                ProductLogic pl = new ProductLogic();
                Product p1 = pl.SelectByProductID(Convert.ToInt32(e.CommandArgument));
                p1.Status = "product approved";
                pl.Update(p1);
                DataTable dt = pl.SelectAllJoined();

                Repeater1.DataSource = dt;
                Repeater1.DataBind();
                if (dt.Rows.Count == 0)
                {
                    Table1.Visible = false;
                    Label1.Visible = true;
                }
                else
                {
                    Table1.Visible = true;
                    Label1.Visible = false;
                }
                TransitionLogic tl = new TransitionLogic();
                Transition t1 = new Transition();
                t1.KeyID = p1.ProductID;
                t1.KeyType = "Prod";
                t1.TranDate = DateTime.Now;
                t1.NewStatus = "product approved";
                t1.Remarks = ((TextBox)e.Item.FindControl("TextBox2")).Text;
                tl.Insert(t1);
            }
        }
        else
        {
            Response.Redirect("Access.aspx");
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        EmployeeLogic el = new EmployeeLogic();
        Employee e2 = el.SelectByID(Convert.ToInt32(Session["EmployeeID"]));
        if (!IsPostBack)
        {
            if (!(e2.Designation.Equals("STOCK MANAGER") || e2.Designation.Equals("STOCK EMPLOYEE") || e2.Designation.Equals("ACCOUNTATANT") || e2.Designation.Equals("HR MANAGER") || e2.Designation.Equals("HR EMPLOYEE")))
            {
                ProductLogic pl = new ProductLogic();
                Product p1 = pl.SelectByProductID(Convert.ToInt32(Request.QueryString["id"])); ;

                if (p1 != null)
                {
                    Label1.Text = p1.Name;
                    Label2.Text = p1.CreateDate.ToString("dd/MM/yyyy");

                    String st = p1.DesignFiles;
                    String[] arr = st.Split(new String[] { "#,#" }, StringSplitOptions.RemoveEmptyEntries);
                    if (arr.Length > 0)
                    {
                        lnkImage1.Text = arr[0].Substring(25);
                        lnkImage1.NavigateUrl = arr[0];
                    }
                    else
                    {
                        lnkImage1.Visible = false;
                    }

                    if (arr.Length > 1)
                    {
                        lnkImage2.Text = arr[1].Substring(25);
                        lnkImage2.NavigateUrl = arr[1];
                    }
                    else
                    {
                        lnkImage2.Visible = false;
                    }
                    if (arr.Length > 2)
                    {
                        lnkImage3.Text = arr[2].Substring(25);
                        lnkImage3.NavigateUrl = arr[2];
                    }
                    else
                    {
                        lnkImage3.Visible = false;
                    }
                    if (arr.Length > 3)
                    {
                        lnkImage4.Text = arr[3].Substring(25);
                        lnkImage4.NavigateUrl = arr[3];
                    }
                    else
                    {
                        lnkImage4.Visible = false;
                    }
                    if (arr.Length > 4)
                    {
                        lnkImage5.Text = arr[4].Substring(25);
                        lnkImage5.NavigateUrl = arr[4];
                    }
                    else
                    {
                        lnkImage5.Visible = false;
                    }
                    Label4.Text = p1.Status;
                    Label5.Text = p1.Description;
                    Label6.Text = p1.Size;
                    Label7.Text = p1.Colors;
                    Label8.Text = p1.Type;

                    CustomerLogic cl = new CustomerLogic();
                    Customer c1 = cl.SelectByID(p1.CustomerID);
                    Label9.Text = c1.Name;

                }
            }
            else
            {
                Response.Redirect("Access.aspx");
            }
        }
    }
예제 #10
0
 public ClientLogic(OrderLogic orderLo, ProductLogic productLo)
 {
     this.orderLo   = orderLo;
     this.productLo = productLo;
 }
    protected void LinkButton5_Click(object sender, EventArgs e)
    {
        ProductLogic pl = new ProductLogic();
        Product p1 = pl.SelectByProductID(Convert.ToInt32(Request.QueryString["id"]));
        String images = p1.DesignFiles;
        String[] arr = images.Split(new String[] { "#,#" }, StringSplitOptions.RemoveEmptyEntries);
        p1.DesignFiles = arr[0] + "#,#";
        p1.DesignFiles += arr[1] + "#,#";
        p1.DesignFiles += arr[2] + "#,#";
        p1.DesignFiles += arr[3] + "#,#";

        pl.Update(p1);
        Response.Redirect("NewProduct.aspx?id=" + Request.QueryString["id"]);

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        if (Convert.ToInt32(Request.QueryString["ID"]) > 0)
        {
            //edit mode
            ProductLogic PL = new ProductLogic();
            Product objPro = PL.SelectByProductID(Convert.ToInt32(Request.QueryString["ID"]));

            objPro.Name = TextBox1.Text;

            if (objPro.Status.Equals(DropDownList3.SelectedItem.Text))
            {
                objPro.Status = DropDownList3.SelectedItem.Text;
            }
            else
            {
                TransitionLogic tl = new TransitionLogic();
                Transition t1 = new Transition();
                t1.KeyID = objPro.ProductID;
                t1.KeyType = "Prod";
                t1.TranDate = DateTime.Now;
                t1.NewStatus = DropDownList3.SelectedItem.Text;
                t1.Remarks = "";
                tl.Insert(t1);
                objPro.Status = DropDownList3.SelectedItem.Text;
            }
            objPro.Description = TextArea1.Text;
            objPro.Size = TextBox4.Text;
            objPro.Colors = TextBox5.Text;
            objPro.Type = DropDownList1.SelectedItem.Text;
            objPro.CustomerID = Convert.ToInt32(DropDownList2.SelectedItem.Value);

            DateTime d1 = new DateTime();
            if (!DateTime.TryParseExact(TextBox2.Text, "dd/MM/yyyy", null, System.Globalization.DateTimeStyles.None, out d1))
            {
                objPro.CreateDate = DateTime.Now;
            }
            if (d1.ToShortDateString().Equals(DateTime.Today.ToShortDateString()))
            {
                objPro.CreateDate = DateTime.Now;
            }
            else
            {
                objPro.CreateDate = d1;
            }
            String path = objPro.DesignFiles;


            string ticks = DateTime.Now.Ticks.ToString();

            if (FileUpload1.HasFile)
            {
                FileUpload1.SaveAs(Server.MapPath("Images/" + ticks + FileUpload1.FileName));

                path += "Images/" + ticks + FileUpload1.FileName + "#,#";
            }
            if (FileUpload2.HasFile)
            {
                FileUpload2.SaveAs(Server.MapPath("Images/" + ticks + FileUpload2.FileName));
                path += "Images/" + ticks + FileUpload2.FileName + "#,#";
            }
            if (FileUpload3.HasFile)
            {
                FileUpload3.SaveAs(Server.MapPath("Images/" + ticks + FileUpload3.FileName));
                path += "Images/" + ticks + FileUpload3.FileName + "#,#";
            }
            if (FileUpload4.HasFile)
            {
                FileUpload4.SaveAs(Server.MapPath("Images/" + ticks + FileUpload4.FileName));
                path += "Images/" + ticks + FileUpload4.FileName + "#,#";
            }
            if (FileUpload5.HasFile)
            {
                FileUpload5.SaveAs(Server.MapPath("Images/" + ticks + FileUpload5.FileName));
                path += "Images/" + ticks + FileUpload5.FileName + "#,#";
            }

            objPro.DesignFiles = path;

            objPro.ProductID = Convert.ToInt32(Request.QueryString["id"]);
            PL.Update(objPro);

            Response.Redirect("ProdList.aspx");
        }
        else
        {
            // insert mode
            Product objPro = new Product();
            objPro.Name = TextBox1.Text;

            objPro.Status =DropDownList3.SelectedItem.Text;
            objPro.Description = TextArea1.Text;
            objPro.Size = TextBox4.Text;
            objPro.Colors = TextBox5.Text;
            objPro.Type = DropDownList1.Text;
            objPro.CustomerID = Convert.ToInt32(DropDownList2.SelectedItem.Value);

            DateTime d1 = new DateTime();
            if (!DateTime.TryParseExact(TextBox2.Text, "dd/MM/yyyy", null, System.Globalization.DateTimeStyles.None, out d1))
            {
                objPro.CreateDate = DateTime.Now;
            }
            if (d1.ToShortDateString().Equals(DateTime.Today.ToShortDateString()))
            {
                objPro.CreateDate = DateTime.Now;
            }
            else
            {
                objPro.CreateDate = d1;
            }

            String path = "";
            string ticks = DateTime.Now.Ticks.ToString();

            if (FileUpload1.HasFile)
            {
                FileUpload1.SaveAs(Server.MapPath("Images/" + ticks + FileUpload1.FileName));

                path += "Images/" + ticks + FileUpload1.FileName + "#,#";
            }
            if (FileUpload2.HasFile)
            {
                FileUpload2.SaveAs(Server.MapPath("Images/" + ticks + FileUpload2.FileName));
                path += "Images/" + ticks + FileUpload2.FileName + "#,#";
            }
            if (FileUpload3.HasFile)
            {
                FileUpload3.SaveAs(Server.MapPath("Images/" + ticks + FileUpload3.FileName));
                path += "Images/" + ticks + FileUpload3.FileName + "#,#";
            }
            if (FileUpload4.HasFile)
            {
                FileUpload4.SaveAs(Server.MapPath("Images/" + ticks + FileUpload4.FileName));
                path += "Images/" + ticks + FileUpload4.FileName + "#,#";
            }
            if (FileUpload5.HasFile)
            {
                FileUpload5.SaveAs(Server.MapPath("Images/" + ticks + FileUpload5.FileName));
                path += "Images/" + ticks + FileUpload5.FileName + "#,#";
            }

            objPro.DesignFiles = path;


            ProductLogic PL = new ProductLogic();
            PL.Insert(objPro);

            Response.Redirect("ProdList.aspx");

        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        EmployeeLogic el = new EmployeeLogic();
        Employee e2 = el.SelectByID(Convert.ToInt32(Session["EmployeeID"]));
       
            if (!IsPostBack)
            {
                if (!(e2.Designation.Equals("STOCK MANAGER") || e2.Designation.Equals("STOCK EMPLOYEE") || e2.Designation.Equals("ACCOUNTATANT") || e2.Designation.Equals("EMPLOYEE") || e2.Designation.Equals("HR MANAGER") || e2.Designation.Equals("HR EMPLOYEE")))
                {

                CustomerLogic sl = new CustomerLogic();
                DropDownList2.DataSource = sl.SelectAll();
                DropDownList2.DataTextField = "Name";
                DropDownList2.DataValueField = "CustomerID";
                DropDownList2.DataBind();
                if (Convert.ToInt32(Request.QueryString["id"]) > 0)
                {
                    // edit mode

                    ProductLogic pl = new ProductLogic();
                    Product p1 = pl.SelectByProductID(Convert.ToInt32(Request.QueryString["id"]));
                    TextBox1.Text = p1.Name;
                    TextBox2.Text = p1.CreateDate.ToString("dd/MM/yyyy");
                   DropDownList3.SelectedItem.Text = p1.Status;
                    TextArea1.Text = p1.Description;
                    TextBox4.Text = p1.Size;
                    TextBox5.Text = p1.Colors;

                    String images = p1.DesignFiles;
                    String[] arr = images.Split(new String[] { "#,#" }, StringSplitOptions.RemoveEmptyEntries);
                    if (arr.Length > 0)
                    {
                        FileUpload1.Visible = false;
                        lnkImage1.Text = arr[0].Substring(25);
                        lnkImage1.NavigateUrl = arr[0];
                    }
                    else
                    {
                        lnkImage1.Visible = false;
                        LinkButton1.Visible = false;
                    }
                    if (arr.Length > 1)
                    {
                        lnkImage2.Text = arr[1].Substring(25);
                        lnkImage2.NavigateUrl = arr[1];
                    }
                    else
                    {
                        lnkImage2.Visible = false;
                        LinkButton2.Visible = false;
                    }
                    if (arr.Length > 2)
                    {
                        lnkImage3.Text = arr[2].Substring(25);
                        lnkImage3.NavigateUrl = arr[2];
                    }
                    else
                    {
                        lnkImage3.Visible = false;
                        LinkButton3.Visible = false;
                    }
                    if (arr.Length > 3)
                    {
                        lnkImage4.Text = arr[3].Substring(25);
                        lnkImage4.NavigateUrl = arr[3];
                    }
                    else
                    {
                        lnkImage4.Visible = false;
                        LinkButton4.Visible = false;
                    }
                    if (arr.Length > 4)
                    {
                        lnkImage5.Text = arr[4].Substring(25);
                        lnkImage5.NavigateUrl = arr[4];
                    }
                    else
                    {
                        lnkImage5.Visible = false;
                        LinkButton5.Visible = false;
                    }

                    DropDownList1.SelectedItem.Text = p1.Type;


                    Customer s = sl.SelectByID(p1.CustomerID);
                    DropDownList2.SelectedItem.Text = s.Name;
                }
                else
                {
                    lnkImage1.Visible = false;
                    lnkImage2.Visible = false;
                    lnkImage3.Visible = false;
                    lnkImage4.Visible = false;
                    lnkImage5.Visible = false;
                    LinkButton1.Visible = false;
                    LinkButton2.Visible = false;
                    LinkButton3.Visible = false;
                    LinkButton4.Visible = false;
                    LinkButton5.Visible = false;
                    TextBox2.Text = DateTime.Now.ToString("dd/MM/yyyy");
                }
            }
                else
                {
                    Response.Redirect("Access.aspx");
                }
        }
       
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        if (Convert.ToInt32(Request.QueryString["ID"]) > 0)
        {
            //edit mode
            if (Convert.ToInt32(TextBox1.Text) > 0)
            {
            OrderLogic ol = new OrderLogic();
            Order o1 = ol.SelectByID(Convert.ToInt32(Request.QueryString["id"]));

            ProductLogic pl = new ProductLogic();
            Product p1 = pl.SelectByProductID(o1.ProductID);
            // = Convert.ToInt32(DropDownList1.SelectedValue) 

           
                o1.ProductID = Convert.ToInt32(DropDownList1.SelectedItem.Value);
                o1.QuotationID = Convert.ToInt32(TextBox1.Text.ToString());
                o1.Quantity = Convert.ToInt32(TextBox2.Text);
                o1.Rate = Convert.ToInt32(TextBox3.Text);
                DateTime d1 = new DateTime();
                if (!DateTime.TryParseExact(TextBox4.Text, "dd/MM/yyyy", null, System.Globalization.DateTimeStyles.None, out d1))
                {
                    d1 = DateTime.Today;
                }
                o1.PODate = d1;

                o1.PONumber = Convert.ToInt32(TextBox5.Text);
                DateTime d2 = new DateTime();
                if (!DateTime.TryParseExact(TextBox6.Text, "dd/MM/yyyy", null, System.Globalization.DateTimeStyles.None, out d2))
                {
                    d2 = DateTime.Today;
                }
                if (d2.ToShortDateString().Equals(DateTime.Today.ToShortDateString()))
                {
                    o1.CreateDate = DateTime.Now;
                }
                else
                {
                    o1.CreateDate = d2;
                }
                if (o1.Status.Equals(DropDownList2.SelectedItem.Text))
                {
                    o1.Status = DropDownList2.SelectedItem.Text;
                }
                else
                {
                    TransitionLogic tl = new TransitionLogic();
                    Transition t1 = new Transition();
                    t1.KeyID = o1.OrderID;
                    t1.KeyType = "Ord";
                    t1.TranDate = DateTime.Now;
                    t1.NewStatus = DropDownList2.SelectedItem.Text;
                    t1.Remarks = "";
                    tl.Insert(t1);

                    o1.Status = DropDownList2.SelectedItem.Text;
                }

                o1.StatusRemarks = TextBox8.Text;
                o1.DeliveryAddress = TextArea2.Text;
                DateTime d3 = new DateTime();
                if (!DateTime.TryParseExact(TextBox9.Text, "dd/MM/yyyy", null, System.Globalization.DateTimeStyles.None, out d3))
                {
                    d3 = DateTime.Today;
                }
                o1.DeliveryDate = d3;

                String po = "";

                string ticks = DateTime.Now.Ticks.ToString();
                if (FileUpload1.HasFile)
                {
                    FileUpload1.SaveAs(Server.MapPath("Images/" + ticks + FileUpload1.FileName));
                    po = "Images/" + ticks + FileUpload1.FileName;
                    o1.AttachPO = po;
                }
               

                ol.Update(o1);

                Response.Redirect("OrderList.aspx");
            }
            else
            {
                Label2.Visible = true;
            }
            

        }
        else
        {
            //Insert mode
            if (Convert.ToInt32(TextBox1.Text) > 0)
            {
                OrderLogic ol = new OrderLogic();
                Order o1 = new Order();

                ProductLogic pl = new ProductLogic();

                o1.ProductID = Convert.ToInt32(DropDownList1.SelectedItem.Value);
                o1.QuotationID = Convert.ToInt32(TextBox1.Text);
                o1.Quantity = Convert.ToInt32(TextBox2.Text);
                o1.Rate = Convert.ToInt32(TextBox3.Text);
                DateTime d1 = new DateTime();
                if (!DateTime.TryParseExact(TextBox4.Text, "dd/MM/yyyy", null, System.Globalization.DateTimeStyles.None, out d1))
                {
                    d1 = DateTime.Today;
                }
                o1.PODate = d1;
                o1.JobPath = "";
                o1.PONumber = Convert.ToInt32(TextBox5.Text);

                DateTime d2 = new DateTime();
                if (!DateTime.TryParseExact(TextBox6.Text, "dd/MM/yyyy", null, System.Globalization.DateTimeStyles.None, out d2))
                {
                    d2 = DateTime.Today;
                }
                if (d2.ToShortDateString().Equals(DateTime.Today.ToShortDateString()))
                {
                    o1.CreateDate = DateTime.Now;
                }
                else
                {
                    o1.CreateDate = d2;
                }

                o1.Status = DropDownList2.SelectedItem.Text;
                o1.StatusRemarks = TextBox8.Text;
                o1.DeliveryAddress = TextArea2.Text;
                DateTime d3 = new DateTime();
                if (!DateTime.TryParseExact(TextBox9.Text, "dd/MM/yyyy", null, System.Globalization.DateTimeStyles.None, out d3))
                {
                    d3 = DateTime.Today;
                }
                o1.DeliveryDate = d3;

                String po = "";

                string ticks = DateTime.Now.Ticks.ToString();
                if (FileUpload1.HasFile)
                {
                    FileUpload1.SaveAs(Server.MapPath("Images/" + ticks + FileUpload1.FileName));
                    po = "Images/" + ticks + FileUpload1.FileName;
                }
                o1.AttachPO = po;
                ol.Insert(o1);

                Response.Redirect("OrderList.aspx");

            }
            else
            {
                Label2.Visible = true;
            }
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        EmployeeLogic el = new EmployeeLogic();
        Employee e2 = el.SelectByID(Convert.ToInt32(Session["EmployeeID"]));
        if (e2.Designation.Equals("COMERCIAL MANAGER") || e2.Designation.Equals("COMERCIAL EMPLOYEE") || e2.Designation.Equals("DESIGNER") || e2.Designation.Equals("PRODUCTION MANAGER") || e2.Designation.Equals("PRODUCTION EMPLOYEE"))
        {
            if (!IsPostBack)
            {

                ProductLogic pl = new ProductLogic();
                DropDownList1.DataSource = pl.SelectAll();
                DropDownList1.DataTextField = "Name";
                DropDownList1.DataValueField = "ProductID";
                DropDownList1.DataBind();

                if (Convert.ToInt32(Request.QueryString["id"]) > 0)
                {

                    OrderLogic ol = new OrderLogic();
                    Order o1 = ol.SelectByID(Convert.ToInt32(Request.QueryString["id"]));

                    Product p1 = pl.SelectByProductID(o1.ProductID);
                    DropDownList1.SelectedItem.Text = p1.Name;
                    QuotationLogic ql = new QuotationLogic();
                    TextBox1.Text = ql.SelectByProductID(Convert.ToInt32(DropDownList1.SelectedValue)).QuotationID.ToString();
                    TextBox2.Text = o1.Quantity.ToString();
                    TextBox3.Text = o1.Rate.ToString();
                    TextBox4.Text = o1.PODate.ToString("dd/MM/yyyy");

                    TextBox5.Text = o1.PONumber.ToString();
                    TextBox6.Text = o1.CreateDate.ToString("dd/MM/yyyy");

                    DropDownList2.SelectedItem.Text = o1.Status;
                    TextBox8.Text = o1.StatusRemarks;
                    TextArea2.Text = o1.DeliveryAddress;
                    TextBox9.Text = o1.DeliveryDate.ToString("dd/MM/yyyy");

                    String po = o1.AttachPO;
                    string ticks = DateTime.Now.Ticks.ToString();
                    if (FileUpload1.HasFile)
                    {
                        FileUpload1.SaveAs(Server.MapPath("Images/" + ticks + FileUpload1.FileName));
                        FileUpload1.Visible = false;
                        lnkImage1.Text = po.Substring(25);
                        lnkImage1.NavigateUrl = po;
                    }
                    else
                    {
                        lnkImage1.Visible = false;
                        LinkButton1.Visible = false;

                    }


                }


                else
                {
                    lnkImage1.Visible = false;
                    LinkButton1.Visible = false;
                    QuotationLogic ql = new QuotationLogic();
                    TextBox1.Text = ql.SelectByProductID(Convert.ToInt32(DropDownList1.SelectedItem.Value)).QuotationID.ToString();
                    TextBox6.Text = DateTime.Now.ToString("dd/MM/yyyy");
                }
            }
            Label2.Visible = false;
        }
        else
        {
            Response.Redirect("Access.aspx");
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        DataTable dt = new AttendanceLogic().SelectForAttendanceReport(DateTime.Today);

        int present = Convert.ToInt32(dt.Rows[0][1]);
        int absent = Convert.ToInt32(dt.Rows[1][1]);


        lblPResentPerc.Text = ((float)present * 100) / ((float)present + absent) + "";
        lblPResentPerc.Attributes.Add("Present", present.ToString());
        lblPResentPerc.Attributes.Add("Absent", absent.ToString());

        DataTable dt1 = new InvoiceLogic().SelectForBestOrder();

        bestOrd.Text = dt1.Rows[0]["ProductName"].ToString();
        totalAmt.Text = dt1.Rows[0]["GrandTotal"].ToString();
        txtCustomer.Text = dt1.Rows[0]["CustomerName"].ToString();
        string dp = dt1.Rows[0]["ProductImage"].ToString();
        String[] arr = dp.Split(new String[] { "#,#" }, StringSplitOptions.RemoveEmptyEntries);
        proimg.Src = arr[arr.Length - 1];

        DataTable dt2 = new InvoiceLogic().SelectForRevenue();
        txtTotIncome.Text = dt2.Rows[0]["TotalIncome"].ToString();

        DataTable dt4 = new InvoiceLogic().SelectIndividualInvoiceAmount();
        string s = "";
        for (int i = 0; i < dt4.Rows.Count; i++)
        {
            s += dt4.Rows[i]["GrandTotal"] + ",";
        }
        s = "[" + s.TrimEnd(',') + "]";
        individualInvoiceAmount.Attributes.Add("data-data", s);


        DataTable dt3 = new ProductLogic().SelectBestProduct();
        OrderNumber.Text = dt3.Rows[0]["Total"].ToString() + " Orders";
        string dp1 = dt3.Rows[0]["DesignFiles"].ToString();
        String[] arr1 = dp1.Split(new String[] { "#,#" }, StringSplitOptions.RemoveEmptyEntries);
        topProimg.Src = arr1[arr1.Length - 1];

        ProName.Text = dt3.Rows[0]["Name"].ToString();
        
        DataTable dt5 = new InvoiceLogic().SelectTotalSale2();
        Repeater2.DataSource = dt5;
        Repeater2.DataBind();
        DataTable dt6 = new InventoryLogic().SelectRawStock();
        Repeater1.DataSource = dt6;
        Repeater1.DataBind();

        CustomerLogic CL = new CustomerLogic();
        Repeater3.DataSource = CL.SelectForReport1();
        Repeater3.DataBind();
        TransitionLogic ol = new TransitionLogic();
        Repeater9.DataSource = ol.SelectProductStatus1(DateTime.Today);
        Repeater9.DataBind();

        TransitionLogic ol2 = new TransitionLogic();
        Repeater4.DataSource = ol2.SelectOrderStatus1(DateTime.Today);
        Repeater4.DataBind();

    }