示例#1
0
        public int Update(ProjectSaleInvoice projectSaleInvoice)
        {
            UpdateCommand.Parameters["@ID"].Value           = projectSaleInvoice.ID;
            UpdateCommand.Parameters["@ReferenceNo"].Value  = projectSaleInvoice.ReferenceNo;
            UpdateCommand.Parameters["@ProjectID"].Value    = projectSaleInvoice.ProjectID;
            UpdateCommand.Parameters["@ProjectName"].Value  = projectSaleInvoice.ProjectName;
            UpdateCommand.Parameters["@CustomerName"].Value = projectSaleInvoice.CustomerName;
            UpdateCommand.Parameters["@Total"].Value        = projectSaleInvoice.Total;
            UpdateCommand.Parameters["@Discount"].Value     = projectSaleInvoice.Discount;
            UpdateCommand.Parameters["@NetTotal"].Value     = projectSaleInvoice.NetTotal;
            UpdateCommand.Parameters["@CreatedDate"].Value  = projectSaleInvoice.CreatedDate;
            UpdateCommand.Parameters["@Username"].Value     = projectSaleInvoice.Username;
            UpdateCommand.Parameters["@Status"].Value       = projectSaleInvoice.Status;

            int returnValue = -1;

            try
            {
                UpdateCommand.Connection.Open();
                returnValue = UpdateCommand.ExecuteNonQuery();
            }
            catch (SqlException ex)
            {
                Logger.Write(ex);
            }
            finally
            {
                UpdateCommand.Connection.Close();
            }
            return(returnValue);
        }
示例#2
0
        private ProjectSaleInvoice DataTableToEntity(DataTable dt)
        {
            ProjectSaleInvoice projectSaleInvoice = new ProjectSaleInvoice();

            if (Null.IsNotNull(dt) == true && dt.Rows.Count > 0)
            {
                if (Null.IsNotNull(dt.Rows[0]))
                {
                    DataRow dr = dt.Rows[0];
                    if (Null.IsNotNull(dr["ID"]))
                    {
                        projectSaleInvoice.ID = Convert.ToInt32(dr["ID"]);
                    }
                    else
                    {
                        projectSaleInvoice.ID = 0;
                    }
                    if (Null.IsNotNull(dr["ReferenceNo"]))
                    {
                        projectSaleInvoice.ReferenceNo = Convert.ToString(dr["ReferenceNo"]);
                    }
                    else
                    {
                        projectSaleInvoice.ReferenceNo = string.Empty;
                    }
                    if (Null.IsNotNull(dr["ProjectID"]))
                    {
                        projectSaleInvoice.ProjectID = Convert.ToInt32(dr["ProjectID"]);
                    }
                    else
                    {
                        projectSaleInvoice.ProjectID = 0;
                    }
                    if (Null.IsNotNull(dr["ProjectName"]))
                    {
                        projectSaleInvoice.ProjectName = Convert.ToString(dr["ProjectName"]);
                    }
                    else
                    {
                        projectSaleInvoice.ProjectName = string.Empty;
                    }
                    if (Null.IsNotNull(dr["CustomerName"]))
                    {
                        projectSaleInvoice.CustomerName = Convert.ToString(dr["CustomerName"]);
                    }
                    else
                    {
                        projectSaleInvoice.CustomerName = string.Empty;
                    }
                    if (Null.IsNotNull(dr["Total"]))
                    {
                        projectSaleInvoice.Total = Convert.ToDecimal(dr["Total"]);
                    }
                    else
                    {
                        projectSaleInvoice.Total = 0.00m;
                    }
                    if (Null.IsNotNull(dr["Discount"]))
                    {
                        projectSaleInvoice.Discount = Convert.ToDecimal(dr["Discount"]);
                    }
                    else
                    {
                        projectSaleInvoice.Discount = 0.00m;
                    }
                    if (Null.IsNotNull(dr["NetTotal"]))
                    {
                        projectSaleInvoice.NetTotal = Convert.ToDecimal(dr["NetTotal"]);
                    }
                    else
                    {
                        projectSaleInvoice.NetTotal = 0.00m;
                    }
                    if (Null.IsNotNull(dr["CreatedDate"]))
                    {
                        projectSaleInvoice.CreatedDate = Convert.ToDateTime(dr["CreatedDate"]);
                    }
                    else
                    {
                        projectSaleInvoice.CreatedDate = DateTime.Now;
                    }
                    if (Null.IsNotNull(dr["Username"]))
                    {
                        projectSaleInvoice.Username = Convert.ToString(dr["Username"]);
                    }
                    else
                    {
                        projectSaleInvoice.Username = string.Empty;
                    }
                    if (Null.IsNotNull(dr["Status"]))
                    {
                        projectSaleInvoice.Status = Convert.ToString(dr["Status"]);
                    }
                    else
                    {
                        projectSaleInvoice.Status = string.Empty;
                    }
                }
            }
            return(projectSaleInvoice);
        }