Пример #1
0
        public static int Insert(Invoiceline c)
        {
            DBAccess db = new DBAccess();

            if (c.Status <= (int)Invoiceline_StatusEnum.Create)
            {
                c.Status = Invoiceline_StatusEnum.Active;
            }
            AddParms(ref db, c);
            SqlParameter objParam = new SqlParameter("@ID", 0);

            objParam.Direction = ParameterDirection.Output;
            db.Parameters.Add(objParam);

            int retval = db.ExecuteNonQuery(_SQLInsert);

            if (retval == 1)
            {
                int res = -1;
                res = Funktioner.ToInteger(objParam.Value);
                AddLog(Status: "Invoiceline", Logtext: string.Format("Create Invoiceline: ID:{0}", c.ID), Metode: "Insert");
                return(res);
            }
            else
            {
                AddLog(Status: "Invoiceline", Logtext: string.Format("Failure to Invoiceline AED_Battery:"), logtype: LogTypeEnum.Error, Metode: "Insert");
                return(-1);
            }
        }
Пример #2
0
        public static string Tags(string tekst, RescueTekniq.BOL.Invoiceline item)
        {
            string        res = "";
            StringBuilder sb  = new StringBuilder();

            sb.Append(tekst);

            sb.Replace("[INVOICE.LINE.POS]", System.Convert.ToString(item.Pos));
            sb.Replace("[INVOICE.LINE.STATUS]", item.Status.ToString());

            sb.Replace("[INVOICE.LINE.ITEMNAME]", item.ItemName);
            sb.Replace("[INVOICE.LINE.ITEMNO]", item.ItemNo);

            sb.Replace("[INVOICE.LINE.QUANTITY]", System.Convert.ToString(item.Quantity));

            sb.Replace("[INVOICE.LINE.ITEMPRICE]", item.ItemPrice.ToString("C"));
            sb.Replace("[INVOICE.LINE.DISCOUNT]", item.Discount.ToString());
            sb.Replace("[INVOICE.LINE.SALESPRICE]", item.SalesPrice.ToString("C"));

            sb.Replace("[INVOICE.LINE.LINETOTAL]", item.LineTotal.ToString("C"));

            //.Replace("[INVOICE.LINE.VAT]", item.VAT.ToString)
            //.Replace("[INVOICE.LINE.FREIGHT]", item.Freight.ToString("C"))

            sb.Replace("[INVOICE.LINE.LINETEXT]", item.LineText);
            sb.Replace("[INVOICE.LINE.SERIALNO]", item.SerialNo);

            res = sb.ToString();
            res = item.KundeGrpPris.Tags(res);
            res = item.Item.Tags(res);

            return(res);
        }
Пример #3
0
        public static System.Collections.Generic.List <Invoiceline> GetInvoiceLineList(int InvoiceID)
        {
            System.Collections.Generic.List <Invoiceline> result = new System.Collections.Generic.List <Invoiceline>();

            DBAccess db = new DBAccess();

            db.AddInt("InvoiceID", InvoiceID);

            SqlDataReader dr = default(SqlDataReader);

            try
            {
                dr = (System.Data.SqlClient.SqlDataReader)(db.ExecuteReader(_SQLSelectAll));  //CType(db.ExecuteReader(_SQLSelectAllID), SqlDataReader)
                if (dr.HasRows)
                {
                    while (dr.Read())
                    {
                        result.Add(Invoiceline.GetInvoiceLine(System.Convert.ToInt32(dr.DBtoInt("ID"))));
                    }
                }
                dr.Close();
            }
            catch (Exception ex)
            {
                throw (ex);
            }

            return(result);
        }
Пример #4
0
        private static void AddParms(ref DBAccess db, Invoiceline c)
        {
            var with_1 = c;

            db.AddInt("InvoiceID", with_1.InvoiceID);
            db.AddInt("Pos", with_1.Pos);
            db.AddInt("Status", (System.Int32)with_1.Status);

            db.AddInt("ItemID", with_1.ItemID);
            db.AddNVarChar("ItemNo", with_1.ItemNo, 50);
            db.AddNVarChar("ItemName", with_1.ItemName, 100);

            db.AddNVarChar("LineText", with_1.LineText, 250);
            db.AddNVarChar("SerialNo", with_1.SerialNo, 250);

            db.AddDecimal("ItemPrice", with_1.ItemPrice);
            db.AddDecimal("Discount", with_1.Discount);
            db.AddDecimal("SalesPrice", with_1.SalesPrice);
            db.AddDecimal("Quantity", with_1.Quantity);
            db.AddDecimal("LineTotal", with_1.LineTotal);

            db.AddBoolean("VAT", with_1.VAT);
            db.AddDecimal("Freight", with_1.Freight);

            db.AddDecimal("ProvisionRate", with_1.ProvisionRate);
            db.AddDecimal("Provision", with_1.Provision);
            db.AddDecimal("LineProvision", with_1.LineProvision);

            AddParmsStandard(db, c);
        }
Пример #5
0
        public static int Save(Invoiceline IL)
        {
            int retval = 0;

            if (IL.ID > 0)
            {
                retval = Update(IL);
            }
            else
            {
                retval = Insert(IL);
            }
            return(retval);
        }
Пример #6
0
        public static int Update(Invoiceline c)
        {
            DBAccess db = new DBAccess();

            db.AddInt("ID", c.ID);
            AddParms(ref db, c);

            int retval = 0;

            //Try
            retval = db.ExecuteNonQuery(_SQLUpdate);
            //Catch
            //End Try
            AddLog(Status: "Invoiceline", Logtext: string.Format("Update Invoiceline: ID:{0}", c.ID), Metode: "Update");
            return(retval);
        }
Пример #7
0
        public static Invoiceline GetInvoiceLine(int ID)
        {
            DBAccess db = new DBAccess();

            db.Parameters.Add(new SqlParameter("@ID", ID));
            SqlDataReader dr = (SqlDataReader)(db.ExecuteReader(_SQLSelectOne));

            if (dr.HasRows)
            {
                Invoiceline c = new Invoiceline();
                while (dr.Read())
                {
                    Populate(dr, c);
                }
                dr.Close();
                return(c);
            }
            else
            {
                dr.Close();
                return(null);
            }
        }
Пример #8
0
        private static void Populate(System.Data.SqlClient.SqlDataReader dr, Invoiceline c)
        {
            var with_1 = c;

            with_1.InvoiceID = System.Convert.ToInt32(dr.DBtoInt("InvoiceID"));
            with_1.Pos       = System.Convert.ToInt32(dr.DBtoInt("Pos"));
            with_1.Status    = (RescueTekniq.BOL.Invoiceline_StatusEnum)(dr.DBtoInt("Status"));

            with_1.ItemID    = System.Convert.ToInt32(dr.DBtoInt("ItemID"));
            with_1._ItemNo   = dr.DBtoString("ItemNo");
            with_1._ItemName = dr.DBtoString("ItemName");

            with_1.LineText = dr.DBtoString("LineText");
            with_1.SerialNo = dr.DBtoString("SerialNo");

            with_1.ItemPrice  = System.Convert.ToDecimal(dr.DBtoDecimal("ItemPrice"));
            with_1.Discount   = System.Convert.ToDecimal(dr.DBtoDecimal("Discount"));
            with_1.SalesPrice = System.Convert.ToDecimal(dr.DBtoDecimal("SalesPrice"));
            with_1.Quantity   = System.Convert.ToDecimal(dr.DBtoDecimal("Quantity"));
            with_1.LineTotal  = System.Convert.ToDecimal(dr.DBtoDecimal("LineTotal"));

            with_1.VAT     = System.Convert.ToBoolean(dr.DBtoBoolean("VAT"));
            with_1.Freight = System.Convert.ToDecimal(dr.DBtoDecimal("Freight"));

            with_1.Provision     = System.Convert.ToDecimal(dr.DBtoDecimal("Provision"));
            with_1.ProvisionRate = System.Convert.ToDecimal(dr.DBtoDecimal("ProvisionRate"));
            with_1.LineProvision = System.Convert.ToDecimal(dr.DBtoDecimal("LineProvision"));

            with_1.CompanyID       = System.Convert.ToInt32(dr.DBtoInt("CompanyID"));
            with_1.InvoiceDate     = System.Convert.ToDateTime(dr.DBtoDateTime("InvoiceDate"));
            with_1.InvoiceStatus   = (RescueTekniq.BOL.Invoice_StatusEnum)(dr.DBtoInt("InvoiceStatus"));
            with_1.InvoicePaid     = System.Convert.ToBoolean(dr.DBtoBoolean("InvoicePaid"));
            with_1.InvoicePaidDate = System.Convert.ToDateTime(dr.DBtoDateTime("InvoicePaidDate"));

            PopulateStandard(dr, c);
        }
Пример #9
0
 public static int Delete(Invoiceline c)
 {
     return(Delete(c.ID));
 }