Beispiel #1
0
        public Boolean Insert(JobworkReturnENT entJobworkReturn)
        {
            using (SqlConnection objConnection = new SqlConnection(ConnectionString))
            {
                using (SqlCommand objcmd = objConnection.CreateCommand())
                {
                    try
                    {
                        objConnection.Open();

                        #region Prepare Command
                        objcmd.CommandType = CommandType.StoredProcedure;
                        objcmd.CommandText = "PR_JobworkReturn_Insert";
                        objcmd.Parameters.AddWithValue("@JobworkOrderID", entJobworkReturn.JobworkOrderID);
                        objcmd.Parameters.AddWithValue("@CustomerID", entJobworkReturn.CustomerID);
                        objcmd.Parameters.AddWithValue("@ProductID", entJobworkReturn.ProductID);
                        objcmd.Parameters.AddWithValue("@IssueGross", entJobworkReturn.IssueGross);
                        objcmd.Parameters.AddWithValue("@ReturnGross", entJobworkReturn.ReturnGross);
                        objcmd.Parameters.AddWithValue("@PendingGross", entJobworkReturn.PendingGross);
                        objcmd.Parameters.AddWithValue("@CompleteGross", entJobworkReturn.CompleteGross);
                        objcmd.Parameters.AddWithValue("@UserID", entJobworkReturn.UserID);
                        objcmd.Parameters.AddWithValue("@CreationDate", entJobworkReturn.CreationDate);

                        #endregion Prepare Command

                        #region ReadData And SetData
                        objcmd.ExecuteNonQuery();

                        return(true);

                        #endregion ReadData And SetData
                    }
                    catch (SqlException Sqlex)
                    {
                        Message = Sqlex.Message.ToString();
                        return(false);
                    }
                    catch (Exception ex)
                    {
                        Message = ex.Message.ToString();
                        return(false);
                    }
                    finally
                    {
                        if (objConnection.State == ConnectionState.Open)
                        {
                            objConnection.Close();
                        }
                    }
                }
            }
        }
        public Boolean Update(JobworkReturnENT entJobworkReturn)
        {
            JobworkReturnDAL dalJobworkReturn = new JobworkReturnDAL();

            if (dalJobworkReturn.Update(entJobworkReturn))
            {
                return(true);
            }
            else
            {
                this.Message = dalJobworkReturn.Message;
                return(false);
            }
        }
    protected void btnSave_Click(object sender, EventArgs e)
    {
        Page.Validate();
        if (Page.IsValid)
        {
            try
            {
                JobworkReturnBAL balJobworkReturn = new JobworkReturnBAL();
                JobworkReturnENT entJobworkReturn = new JobworkReturnENT();

                #region 15.1 Validate Fields

                String ErrorMsg = String.Empty;

                if (ddlCustomer.SelectedIndex <= 0 || ddlCustomer.SelectedValue == "-99")
                {
                    ErrorMsg += " Order Name";
                }

                if (ErrorMsg != String.Empty)
                {
                    lblMessage.Text = ErrorMsg;

                    lblMessage.ForeColor = Color.Red;
                    return;
                }
                #endregion 15.1 Validate Fields


                #region 15.2 Gather Data
                foreach (GridViewRow row in gvJobworkReturn.Rows)
                {
                    //entJobworkReturn.JobworkReturnID = 23;
                    entJobworkReturn.JobworkReturnID = Convert.ToInt32(((HiddenField)row.Cells[6].FindControl("hfJobworkReturnID")).Value);
                    entJobworkReturn = balJobworkReturn.SelectByPK(entJobworkReturn.JobworkReturnID);

                    TextBox txt = (TextBox)row.Cells[6].FindControl("txtCompleteGross");
                    string  txtCompleteGross = txt.Text;

                    if (txtCompleteGross.Trim() != String.Empty)
                    {
                        entJobworkReturn.CompleteGross = Convert.ToInt32(txtCompleteGross);
                    }
                    else
                    {
                        entJobworkReturn.CompleteGross = 0;
                    }
                    //  entJobworkReturn.JobworkOrderID = Convert.ToInt32((txtCompleteGross.FindControl("hfJobWorkOrderID") as HiddenField).Value);
                    //if (txtCompleteGross.Text.Trim() != String.Empty)
                    //    entJobworkReturn.CompleteGross = Convert.ToInt32(txtCompleteGross.Text);

                    //entJobworkReturn.JobworkOrderID = Convert.ToInt32(((HiddenField)gvJobworkReturn.SelectedRow.FindControl("hfJobWorkOrderID")).Value);
                    //entJobworkReturn.JobworkOrderID = entJobworkReturn.JobworkOrderID;

                    //if (ddlCustomer.SelectedIndex > 0)
                    //    entJobworkReturn.CustomerID = Convert.ToInt32(ddlCustomer.SelectedValue);

                    //entJobworkReturn.ProductID = entJobworkReturn.ProductID;


                    //entJobworkReturn.IssueGross = entJobworkReturn.IssueGross;

                    //entJobworkReturn.ReturnGross = entJobworkReturn.ReturnGross;

                    //entJobworkReturn.PendingGross = entJobworkReturn.PendingGross;

                    entJobworkReturn.UserID = Convert.ToInt32(Session["UserID"]);

                    entJobworkReturn.CreationDate = DateTime.Now;

                    balJobworkReturn.Update(entJobworkReturn);
                }

                #endregion 15.2 Gather Data

                #region 15.3 Insert,Update,Copy
                if (Page.RouteData.Values["JobworkReturnID"] == null)
                {
                    FillJobworkReturnGridView(Convert.ToInt32(ddlCustomer.SelectedValue));
                }

                #endregion 15.3 Insert,Update,Copy
            }
            catch (Exception ex)
            {
                lblMessage.Text = ex.Message;
                //lblMessage.CssClass = CSSClass.alertdanger;
                lblMessage.ForeColor = Color.Red;
            }
        }
    }
Beispiel #4
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        #region ServerSide Validation


        #endregion ServerSide Validations

        JobworkOrderENT entJobworkOrder = new JobworkOrderENT();
        JobworkOrderBAL balJobworkOrder = new JobworkOrderBAL();

        JobworkReturnENT entJobworkReturn = new JobworkReturnENT();
        JobworkReturnBAL balJobworkReturn = new JobworkReturnBAL();

        #region Gather Data
        if (ddlCustomer.SelectedIndex > 0)
        {
            entJobworkOrder.CustomerID  = Convert.ToInt32(ddlCustomer.SelectedValue);
            entJobworkReturn.CustomerID = Convert.ToInt32(ddlCustomer.SelectedValue);
        }
        if (ddlProduct.SelectedIndex > 0)
        {
            entJobworkOrder.ProductID  = Convert.ToInt32(ddlProduct.SelectedValue);
            entJobworkReturn.ProductID = Convert.ToInt32(ddlProduct.SelectedValue);
        }
        if (txtGross.Text.Trim() != String.Empty)
        {
            entJobworkOrder.Gross         = Convert.ToInt32(txtGross.Text.Trim());
            entJobworkReturn.IssueGross   = Convert.ToInt32(txtGross.Text.Trim());
            entJobworkReturn.PendingGross = Convert.ToInt32(txtGross.Text.Trim());
        }
        if (txtRate.Text.Trim() != String.Empty)
        {
            entJobworkOrder.Rate = Convert.ToInt32(txtRate.Text.Trim());
        }
        if (txtIssueDate.Text.Trim() != String.Empty)
        {
            entJobworkOrder.IssueDate = Convert.ToDateTime(txtIssueDate.Text.Trim());
        }
        if (txtReturnDate.Text.Trim() != String.Empty)
        {
            entJobworkOrder.ReturnDate = Convert.ToDateTime(txtReturnDate.Text.Trim());
        }

        entJobworkReturn.ReturnGross = 0;

        entJobworkOrder.CreationDate  = DateTime.Now;
        entJobworkReturn.CreationDate = DateTime.Now;

        entJobworkOrder.UserID  = Convert.ToInt32(Session["UserID"]);
        entJobworkReturn.UserID = Convert.ToInt32(Session["UserID"]);

        if (Request.QueryString["JobworkOrderID"] == null)
        {
            Int32 JobworkOrderID = balJobworkOrder.Insert(entJobworkOrder);
            if (JobworkOrderID > 0)
            {
                entJobworkReturn.JobworkOrderID = JobworkOrderID;
            }

            balJobworkReturn.Insert(entJobworkReturn);

            lblMessage.Text = "Data Insert SuccessFully";
            ClearControl();
        }
        else
        {
            entJobworkOrder.JobworkOrderID = Convert.ToInt32(Request.QueryString["JobworkOrderID"]);
            balJobworkOrder.Update(entJobworkOrder);
            Response.Redirect("~/AdminPanel/JobworkOrder/JobworkOrderList.aspx");
        }

        #endregion Gather Data
    }
Beispiel #5
0
        public JobworkReturnENT SelectByPK(SqlInt32 JobworkReturnID)
        {
            using (SqlConnection objConnection = new SqlConnection(ConnectionString))
            {
                using (SqlCommand objcmd = objConnection.CreateCommand())
                {
                    try
                    {
                        objConnection.Open();

                        #region Prepare Command
                        objcmd.CommandType = CommandType.StoredProcedure;
                        objcmd.CommandText = "PR_JobworkReturn_SelectByPK";
                        objcmd.Parameters.AddWithValue("@JobworkReturnID", JobworkReturnID.ToString());
                        #endregion Prepare Command

                        #region ReadData And SetData
                        JobworkReturnENT entJobworkReturn = new JobworkReturnENT();
                        using (SqlDataReader objSDR = objcmd.ExecuteReader())
                        {
                            while (objSDR.Read())
                            {
                                if (!objSDR["JobworkReturnID"].Equals(DBNull.Value))
                                {
                                    entJobworkReturn.JobworkReturnID = Convert.ToInt32(objSDR["JobworkReturnID"]);
                                }
                                if (!objSDR["JobworkOrderID"].Equals(DBNull.Value))
                                {
                                    entJobworkReturn.JobworkOrderID = Convert.ToInt32(objSDR["JobworkOrderID"]);
                                }

                                if (!objSDR["CustomerID"].Equals(DBNull.Value))
                                {
                                    entJobworkReturn.CustomerID = Convert.ToInt32(objSDR["CustomerID"]);
                                }
                                if (!objSDR["ProductID"].Equals(DBNull.Value))
                                {
                                    entJobworkReturn.ProductID = Convert.ToInt32(objSDR["ProductID"]);
                                }
                                if (!objSDR["IssueGross"].Equals(DBNull.Value))
                                {
                                    entJobworkReturn.IssueGross = Convert.ToInt32(objSDR["IssueGross"]);
                                }
                                if (!objSDR["ReturnGross"].Equals(DBNull.Value))
                                {
                                    entJobworkReturn.ReturnGross = Convert.ToInt32(objSDR["ReturnGross"]);
                                }
                                if (!objSDR["PendingGross"].Equals(DBNull.Value))
                                {
                                    entJobworkReturn.PendingGross = Convert.ToInt32(objSDR["PendingGross"]);
                                }
                                if (!objSDR["CompleteGross"].Equals(DBNull.Value))
                                {
                                    entJobworkReturn.CompleteGross = Convert.ToInt32(objSDR["CompleteGross"]);
                                }
                            }
                        }

                        return(entJobworkReturn);

                        #endregion ReadData And SetData
                    }
                    catch (SqlException Sqlex)
                    {
                        Message = Sqlex.Message.ToString();
                        return(null);
                    }
                    catch (Exception ex)
                    {
                        Message = ex.Message.ToString();
                        return(null);
                    }
                    finally
                    {
                        if (objConnection.State == ConnectionState.Open)
                        {
                            objConnection.Close();
                        }
                    }
                }
            }
        }