Exemplo n.º 1
0
        public int Update(SaleQuotation saleQuotation)
        {
            UpdateCommand.Parameters["@ID"].Value              = saleQuotation.ID;
            UpdateCommand.Parameters["@ReferenceNo"].Value     = saleQuotation.ReferenceNo;
            UpdateCommand.Parameters["@InventoryItemID"].Value = saleQuotation.InventoryItemID;
            UpdateCommand.Parameters["@ItemName"].Value        = saleQuotation.ItemName;
            UpdateCommand.Parameters["@Description"].Value     = saleQuotation.Description;
            UpdateCommand.Parameters["@Price"].Value           = saleQuotation.Price;
            UpdateCommand.Parameters["@Qty"].Value             = saleQuotation.Qty;
            UpdateCommand.Parameters["@Amount"].Value          = saleQuotation.Amount;
            UpdateCommand.Parameters["@Status"].Value          = saleQuotation.Status;

            int returnValue = -1;

            try
            {
                UpdateCommand.Connection.Open();
                returnValue = UpdateCommand.ExecuteNonQuery();
            }
            catch (SqlException ex)
            {
                Logger.Write(ex);
            }
            finally
            {
                UpdateCommand.Connection.Close();
            }
            return(returnValue);
        }
Exemplo n.º 2
0
        public int Insert(SaleQuotation saleQuotation)
        {
            InsertCommand.Parameters["@ReferenceNo"].Value     = saleQuotation.ReferenceNo;
            InsertCommand.Parameters["@InventoryItemID"].Value = saleQuotation.InventoryItemID;
            InsertCommand.Parameters["@ItemName"].Value        = saleQuotation.ItemName;
            InsertCommand.Parameters["@Description"].Value     = saleQuotation.Description;
            InsertCommand.Parameters["@Price"].Value           = saleQuotation.Price;
            InsertCommand.Parameters["@Qty"].Value             = saleQuotation.Qty;
            InsertCommand.Parameters["@Amount"].Value          = saleQuotation.Amount;
            InsertCommand.Parameters["@Status"].Value          = saleQuotation.Status;


            int returnValue = -1;

            try
            {
                InsertCommand.Connection.Open();
                returnValue = (int)InsertCommand.ExecuteScalar();
            }
            catch (SqlException ex)
            {
                Logger.Write(ex);
            }
            finally
            {
                InsertCommand.Connection.Close();
            }
            return(returnValue);
        }
Exemplo n.º 3
0
        private SaleQuotation DataTableToEntity(DataTable dt)
        {
            SaleQuotation saleQuotation = new SaleQuotation();

            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"]))
                    {
                        saleQuotation.ID = Convert.ToInt32(dr["ID"]);
                    }
                    else
                    {
                        saleQuotation.ID = 0;
                    }
                    if (Null.IsNotNull(dr["ReferenceNo"]))
                    {
                        saleQuotation.ReferenceNo = Convert.ToString(dr["ReferenceNo"]);
                    }
                    else
                    {
                        saleQuotation.ReferenceNo = string.Empty;
                    }
                    if (Null.IsNotNull(dr["InventoryItemID"]))
                    {
                        saleQuotation.InventoryItemID = Convert.ToInt32(dr["InventoryItemID"]);
                    }
                    else
                    {
                        saleQuotation.InventoryItemID = 0;
                    }
                    if (Null.IsNotNull(dr["ItemName"]))
                    {
                        saleQuotation.ItemName = Convert.ToString(dr["ItemName"]);
                    }
                    else
                    {
                        saleQuotation.ItemName = string.Empty;
                    }
                    if (Null.IsNotNull(dr["Description"]))
                    {
                        saleQuotation.Description = Convert.ToString(dr["Description"]);
                    }
                    else
                    {
                        saleQuotation.Description = string.Empty;
                    }
                    if (Null.IsNotNull(dr["Price"]))
                    {
                        saleQuotation.Price = Convert.ToDecimal(dr["Price"]);
                    }
                    else
                    {
                        saleQuotation.Price = 0.00m;
                    }
                    if (Null.IsNotNull(dr["Qty"]))
                    {
                        saleQuotation.Qty = Convert.ToInt32(dr["Qty"]);
                    }
                    else
                    {
                        saleQuotation.Qty = 0;
                    }
                    if (Null.IsNotNull(dr["Amount"]))
                    {
                        saleQuotation.Amount = Convert.ToDecimal(dr["Amount"]);
                    }
                    else
                    {
                        saleQuotation.Amount = 0.00m;
                    }
                    if (Null.IsNotNull(dr["Status"]))
                    {
                        saleQuotation.Status = Convert.ToString(dr["Status"]);
                    }
                    else
                    {
                        saleQuotation.Status = string.Empty;
                    }
                }
            }
            return(saleQuotation);
        }