/*
 protected void ImageButton1_Command(object sender, CommandEventArgs e)
 {
     OrderLogic ol = new OrderLogic();
     Order o1 = ol.SelectByID(Convert.ToInt32(e.CommandArgument));
     o1.Status = "Performa invoice generated";
     ol.Update(o1);
 }
 protected void ImageButton2_Command(object sender, CommandEventArgs e)
 {
     OrderLogic ol = new OrderLogic();
     Order o1 = ol.SelectByID(Convert.ToInt32(e.CommandArgument));
     o1.Status = "Performa invoice approved";
     ol.Update(o1);
 }
 protected void ImageButton3_Command(object sender, CommandEventArgs e)
 {
     OrderLogic ol = new OrderLogic();
     Order o1 = ol.SelectByID(Convert.ToInt32(e.CommandArgument));
     o1.Status = "Cylinder requested";
     ol.Update(o1);
 }
 protected void ImageButton4_Command(object sender, CommandEventArgs e)
 {
     OrderLogic ol = new OrderLogic();
     Order o1 = ol.SelectByID(Convert.ToInt32(e.CommandArgument));
     o1.Status = "Cylinder received";
     ol.Update(o1);
 }
 protected void ImageButton5_Command(object sender, CommandEventArgs e)
 {
     OrderLogic ol = new OrderLogic();
     Order o1 = ol.SelectByID(Convert.ToInt32(e.CommandArgument));
     o1.Status = "Print pending";
     ol.Update(o1);
 }
 protected void ImageButton6_Command(object sender, CommandEventArgs e)
 {
     OrderLogic ol = new OrderLogic();
     Order o1 = ol.SelectByID(Convert.ToInt32(e.CommandArgument));
     o1.Status = "Converting";
     ol.Update(o1);
 }
 protected void ImageButton7_Command(object sender, CommandEventArgs e)
 {
     OrderLogic ol = new OrderLogic();
     Order o1 = ol.SelectByID(Convert.ToInt32(e.CommandArgument));
     o1.Status = "Ready";
     ol.Update(o1);
 }
 protected void ImageButton8_Command(object sender, CommandEventArgs e)
 {
     OrderLogic ol = new OrderLogic();
     Order o1 = ol.SelectByID(Convert.ToInt32(e.CommandArgument));
     o1.Status = "Dispached";
     ol.Update(o1);
 }
 protected void ImageButton9_Command(object sender, CommandEventArgs e)
 {
     OrderLogic ol = new OrderLogic();
     Order o1 = ol.SelectByID(Convert.ToInt32(e.CommandArgument));
     o1.Status = "Closed";
     ol.Update(o1);
 }*/
 protected void Repeater1_ItemCommand(object source, RepeaterCommandEventArgs e)
 {
       EmployeeLogic el = new EmployeeLogic();
     Employee e2 = el.SelectByID(Convert.ToInt32(Session["EmployeeID"]));
     if (!(e2.Designation.Equals("ACCOUNTATANT") || e2.Designation.Equals("HR MANAGER") || e2.Designation.Equals("HR EMPLOYEE")))
     {
         if(e.CommandName.Equals("Performa invoice generated")){
             OrderLogic ol = new OrderLogic();
             Order o1 = ol.SelectByID(Convert.ToInt32(e.CommandArgument));
             o1.Status = "Performa invoice generated";
             ol.Update(o1);
             DataTable dt = ol.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 = o1.OrderID;
             t1.KeyType = "Ord";
             t1.TranDate = DateTime.Now;
             t1.NewStatus = "Performa invoice generated";
             t1.Remarks = ((TextBox)e.Item.FindControl("TextBox3")).Text;
             tl.Insert(t1);
         }else if(e.CommandName.Equals("Performa invoice approved")){
             OrderLogic ol = new OrderLogic();
             Order o1 = ol.SelectByID(Convert.ToInt32(e.CommandArgument));
             o1.Status = "Performa invoice approved";
             ol.Update(o1);
             DataTable dt = ol.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 = o1.OrderID;
             t1.KeyType = "Ord";
             t1.TranDate = DateTime.Now;
             t1.NewStatus = "Performa invoice approved";
             t1.Remarks = ((TextBox)e.Item.FindControl("TextBox3")).Text;
             tl.Insert(t1);
         }else if(e.CommandName.Equals("Cylinder requested")){
             OrderLogic ol = new OrderLogic();
             Order o1 = ol.SelectByID(Convert.ToInt32(e.CommandArgument));
             o1.Status = "Cylinder requested";
             ol.Update(o1);
             DataTable dt = ol.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 = o1.OrderID;
             t1.KeyType = "Ord";
             t1.TranDate = DateTime.Now;
             t1.NewStatus = "Cylinder requested";
             t1.Remarks = ((TextBox)e.Item.FindControl("TextBox3")).Text;
             tl.Insert(t1);
         }else if(e.CommandName.Equals("Cylinder received")){
             OrderLogic ol = new OrderLogic();
             Order o1 = ol.SelectByID(Convert.ToInt32(e.CommandArgument));
             o1.Status = "Cylinder received";
             ol.Update(o1);
             DataTable dt = ol.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 = o1.OrderID;
             t1.KeyType = "Ord";
             t1.TranDate = DateTime.Now;
             t1.NewStatus = "Cylinder received";
             t1.Remarks = ((TextBox)e.Item.FindControl("TextBox3")).Text;
             tl.Insert(t1);
         }else if(e.CommandName.Equals("Print pending")){
             OrderLogic ol = new OrderLogic();
             Order o1 = ol.SelectByID(Convert.ToInt32(e.CommandArgument));
             o1.Status = "Print pending";
             ol.Update(o1);
             DataTable dt = ol.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 = o1.OrderID;
             t1.KeyType = "Ord";
             t1.TranDate = DateTime.Now;
             t1.NewStatus = "Print pending";
             t1.Remarks = ((TextBox)e.Item.FindControl("TextBox3")).Text;
             tl.Insert(t1);
         }else if(e.CommandName.Equals("Converting")){
             OrderLogic ol = new OrderLogic();
             Order o1 = ol.SelectByID(Convert.ToInt32(e.CommandArgument));
             o1.Status = "Converting";
             ol.Update(o1);
             DataTable dt = ol.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 = o1.OrderID;
             t1.KeyType = "Ord";
             t1.TranDate = DateTime.Now;
             t1.NewStatus = "Converting";
             t1.Remarks = ((TextBox)e.Item.FindControl("TextBox3")).Text;
             tl.Insert(t1);
         }else if(e.CommandName.Equals("Ready")){
             OrderLogic ol = new OrderLogic();
             Order o1 = ol.SelectByID(Convert.ToInt32(e.CommandArgument));
             o1.Status = "Ready";
             ol.Update(o1);
             DataTable dt = ol.SelectAllJoined();
             Repeater1.DataSource = dt;
             Repeater1.DataBind();
             TransitionLogic tl = new TransitionLogic();
             Transition t1 = new Transition();
             t1.KeyID = o1.OrderID;
             t1.KeyType = "Ord";
             t1.TranDate = DateTime.Now;
             t1.NewStatus = "Ready";
             t1.Remarks = ((TextBox)e.Item.FindControl("TextBox3")).Text;
             tl.Insert(t1);
         }else if(e.CommandName.Equals("Dispached")){
             OrderLogic ol = new OrderLogic();
             Order o1 = ol.SelectByID(Convert.ToInt32(e.CommandArgument));
             o1.Status = "Dispached";
             ol.Update(o1);
             DataTable dt = ol.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 = o1.OrderID;
             t1.KeyType = "Ord";
             t1.TranDate = DateTime.Now;
             t1.NewStatus = "Dispached";
             t1.Remarks = ((TextBox)e.Item.FindControl("TextBox3")).Text;
             tl.Insert(t1);
         }else if(e.CommandName.Equals("Closed")){
             OrderLogic ol = new OrderLogic();
             Order o1 = ol.SelectByID(Convert.ToInt32(e.CommandArgument));
             o1.Status = "Closed";
             ol.Update(o1);
             DataTable dt = ol.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 = o1.OrderID;
             t1.KeyType = "Ord";
             t1.TranDate = DateTime.Now;
             t1.NewStatus = "Closed";
             t1.Remarks = ((TextBox)e.Item.FindControl("TextBox3")).Text;
             tl.Insert(t1);
         }
     }
     else
     {
         Response.Redirect("Access.aspx");
     }
     
 }
    /*
     * protected void ImageButton1_Command(object sender, CommandEventArgs e)
     * {
     *  OrderLogic ol = new OrderLogic();
     *  Order o1 = ol.SelectByID(Convert.ToInt32(e.CommandArgument));
     *  o1.Status = "Performa invoice generated";
     *  ol.Update(o1);
     * }
     * protected void ImageButton2_Command(object sender, CommandEventArgs e)
     * {
     *  OrderLogic ol = new OrderLogic();
     *  Order o1 = ol.SelectByID(Convert.ToInt32(e.CommandArgument));
     *  o1.Status = "Performa invoice approved";
     *  ol.Update(o1);
     * }
     * protected void ImageButton3_Command(object sender, CommandEventArgs e)
     * {
     *  OrderLogic ol = new OrderLogic();
     *  Order o1 = ol.SelectByID(Convert.ToInt32(e.CommandArgument));
     *  o1.Status = "Cylinder requested";
     *  ol.Update(o1);
     * }
     * protected void ImageButton4_Command(object sender, CommandEventArgs e)
     * {
     *  OrderLogic ol = new OrderLogic();
     *  Order o1 = ol.SelectByID(Convert.ToInt32(e.CommandArgument));
     *  o1.Status = "Cylinder received";
     *  ol.Update(o1);
     * }
     * protected void ImageButton5_Command(object sender, CommandEventArgs e)
     * {
     *  OrderLogic ol = new OrderLogic();
     *  Order o1 = ol.SelectByID(Convert.ToInt32(e.CommandArgument));
     *  o1.Status = "Print pending";
     *  ol.Update(o1);
     * }
     * protected void ImageButton6_Command(object sender, CommandEventArgs e)
     * {
     *  OrderLogic ol = new OrderLogic();
     *  Order o1 = ol.SelectByID(Convert.ToInt32(e.CommandArgument));
     *  o1.Status = "Converting";
     *  ol.Update(o1);
     * }
     * protected void ImageButton7_Command(object sender, CommandEventArgs e)
     * {
     *  OrderLogic ol = new OrderLogic();
     *  Order o1 = ol.SelectByID(Convert.ToInt32(e.CommandArgument));
     *  o1.Status = "Ready";
     *  ol.Update(o1);
     * }
     * protected void ImageButton8_Command(object sender, CommandEventArgs e)
     * {
     *  OrderLogic ol = new OrderLogic();
     *  Order o1 = ol.SelectByID(Convert.ToInt32(e.CommandArgument));
     *  o1.Status = "Dispached";
     *  ol.Update(o1);
     * }
     * protected void ImageButton9_Command(object sender, CommandEventArgs e)
     * {
     *  OrderLogic ol = new OrderLogic();
     *  Order o1 = ol.SelectByID(Convert.ToInt32(e.CommandArgument));
     *  o1.Status = "Closed";
     *  ol.Update(o1);
     * }*/
    protected void Repeater1_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
        EmployeeLogic el = new EmployeeLogic();
        Employee      e2 = el.SelectByID(Convert.ToInt32(Session["EmployeeID"]));

        if (!(e2.Designation.Equals("ACCOUNTATANT") || e2.Designation.Equals("HR MANAGER") || e2.Designation.Equals("HR EMPLOYEE")))
        {
            if (e.CommandName.Equals("Performa invoice generated"))
            {
                OrderLogic ol = new OrderLogic();
                Order      o1 = ol.SelectByID(Convert.ToInt32(e.CommandArgument));
                o1.Status = "Performa invoice generated";
                ol.Update(o1);
                DataTable dt = ol.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     = o1.OrderID;
                t1.KeyType   = "Ord";
                t1.TranDate  = DateTime.Now;
                t1.NewStatus = "Performa invoice generated";
                t1.Remarks   = ((TextBox)e.Item.FindControl("TextBox3")).Text;
                tl.Insert(t1);
            }
            else if (e.CommandName.Equals("Performa invoice approved"))
            {
                OrderLogic ol = new OrderLogic();
                Order      o1 = ol.SelectByID(Convert.ToInt32(e.CommandArgument));
                o1.Status = "Performa invoice approved";
                ol.Update(o1);
                DataTable dt = ol.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     = o1.OrderID;
                t1.KeyType   = "Ord";
                t1.TranDate  = DateTime.Now;
                t1.NewStatus = "Performa invoice approved";
                t1.Remarks   = ((TextBox)e.Item.FindControl("TextBox3")).Text;
                tl.Insert(t1);
            }
            else if (e.CommandName.Equals("Cylinder requested"))
            {
                OrderLogic ol = new OrderLogic();
                Order      o1 = ol.SelectByID(Convert.ToInt32(e.CommandArgument));
                o1.Status = "Cylinder requested";
                ol.Update(o1);
                DataTable dt = ol.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     = o1.OrderID;
                t1.KeyType   = "Ord";
                t1.TranDate  = DateTime.Now;
                t1.NewStatus = "Cylinder requested";
                t1.Remarks   = ((TextBox)e.Item.FindControl("TextBox3")).Text;
                tl.Insert(t1);
            }
            else if (e.CommandName.Equals("Cylinder received"))
            {
                OrderLogic ol = new OrderLogic();
                Order      o1 = ol.SelectByID(Convert.ToInt32(e.CommandArgument));
                o1.Status = "Cylinder received";
                ol.Update(o1);
                DataTable dt = ol.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     = o1.OrderID;
                t1.KeyType   = "Ord";
                t1.TranDate  = DateTime.Now;
                t1.NewStatus = "Cylinder received";
                t1.Remarks   = ((TextBox)e.Item.FindControl("TextBox3")).Text;
                tl.Insert(t1);
            }
            else if (e.CommandName.Equals("Print pending"))
            {
                OrderLogic ol = new OrderLogic();
                Order      o1 = ol.SelectByID(Convert.ToInt32(e.CommandArgument));
                o1.Status = "Print pending";
                ol.Update(o1);
                DataTable dt = ol.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     = o1.OrderID;
                t1.KeyType   = "Ord";
                t1.TranDate  = DateTime.Now;
                t1.NewStatus = "Print pending";
                t1.Remarks   = ((TextBox)e.Item.FindControl("TextBox3")).Text;
                tl.Insert(t1);
            }
            else if (e.CommandName.Equals("Converting"))
            {
                OrderLogic ol = new OrderLogic();
                Order      o1 = ol.SelectByID(Convert.ToInt32(e.CommandArgument));
                o1.Status = "Converting";
                ol.Update(o1);
                DataTable dt = ol.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     = o1.OrderID;
                t1.KeyType   = "Ord";
                t1.TranDate  = DateTime.Now;
                t1.NewStatus = "Converting";
                t1.Remarks   = ((TextBox)e.Item.FindControl("TextBox3")).Text;
                tl.Insert(t1);
            }
            else if (e.CommandName.Equals("Ready"))
            {
                OrderLogic ol = new OrderLogic();
                Order      o1 = ol.SelectByID(Convert.ToInt32(e.CommandArgument));
                o1.Status = "Ready";
                ol.Update(o1);
                DataTable dt = ol.SelectAllJoined();
                Repeater1.DataSource = dt;
                Repeater1.DataBind();
                TransitionLogic tl = new TransitionLogic();
                Transition      t1 = new Transition();
                t1.KeyID     = o1.OrderID;
                t1.KeyType   = "Ord";
                t1.TranDate  = DateTime.Now;
                t1.NewStatus = "Ready";
                t1.Remarks   = ((TextBox)e.Item.FindControl("TextBox3")).Text;
                tl.Insert(t1);
            }
            else if (e.CommandName.Equals("Dispached"))
            {
                OrderLogic ol = new OrderLogic();
                Order      o1 = ol.SelectByID(Convert.ToInt32(e.CommandArgument));
                o1.Status = "Dispached";
                ol.Update(o1);
                DataTable dt = ol.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     = o1.OrderID;
                t1.KeyType   = "Ord";
                t1.TranDate  = DateTime.Now;
                t1.NewStatus = "Dispached";
                t1.Remarks   = ((TextBox)e.Item.FindControl("TextBox3")).Text;
                tl.Insert(t1);
            }
            else if (e.CommandName.Equals("Closed"))
            {
                OrderLogic ol = new OrderLogic();
                Order      o1 = ol.SelectByID(Convert.ToInt32(e.CommandArgument));
                o1.Status = "Closed";
                ol.Update(o1);
                DataTable dt = ol.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     = o1.OrderID;
                t1.KeyType   = "Ord";
                t1.TranDate  = DateTime.Now;
                t1.NewStatus = "Closed";
                t1.Remarks   = ((TextBox)e.Item.FindControl("TextBox3")).Text;
                tl.Insert(t1);
            }
        }
        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 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;
            }
        }
    }
Ejemplo n.º 5
0
    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 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 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;
            }
        }
    }
Ejemplo n.º 8
0
    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");
        }
    }