コード例 #1
0
        public static int Delete(int ID)
        {
            InvoiceHeader IH = new InvoiceHeader();

            IH.ID = ID;
            return(Delete(IH));
        }
コード例 #2
0
        public static System.Collections.Generic.List <InvoiceHeader> GetInvoiceList(int CompanyID, Invoice_StatusEnum Status, int EANInvoice)
        {
            System.Collections.Generic.List <InvoiceHeader> result = new System.Collections.Generic.List <InvoiceHeader>();
            DBAccess db = new DBAccess();

            db.AddInt("CompanyID", CompanyID);
            db.AddInt("Status", System.Convert.ToInt32(Status));
            db.AddInt("EANInvoice", EANInvoice);

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

            return(result);
        }
コード例 #3
0
        public static int Update(InvoiceHeader c)
        {
            DBAccess db = new DBAccess();

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

            int retval = db.ExecuteNonQuery(_SQLUpdate);

            AddLog(Status: "InvoiceHeader", Logtext: string.Format("Update InvoiceHeader: ID:{0}", c.ID), Metode: "Update");
            return(retval);
        }
コード例 #4
0
        public static int Delete(InvoiceHeader IH)
        {
            foreach (Invoiceline IL in IH.Invoiceslinier)
            {
                IL.Delete();
            }
            DBAccess db = new DBAccess();

            db.AddInt("ID", IH.ID);
            int retval = db.ExecuteNonQuery(_SQLDelete);

            AddLog(Status: "InvoiceHeader", Logtext: string.Format("Delete InvoiceHeader: ID:{0}", IH.ID), Metode: "Delete");
            return(retval);
        }
コード例 #5
0
        public static int SetPaid(int ID, DateTime PaidDate)
        {
            DBAccess db = new DBAccess();

            InvoiceHeader c = new InvoiceHeader(ID);

            db.AddInt("ID", ID);
            db.AddInt("Status", System.Convert.ToInt32(Invoiceline_StatusEnum.Payed));
            db.AddDateTime("PaidDate", PaidDate);
            AddParmsStandard(db, c);

            int retval = db.ExecuteNonQuery(_SQLSetPaid);

            AddLog(Status: "InvoiceHeader", Logtext: string.Format("SetPaid InvoiceHeader: ID:{0} Paid:{1} Status:{2}", c.ID, c.PaidDate, c.StatusText), Metode: "SetPaid");
            return(retval);
        }
コード例 #6
0
        public static int SetStatus(int ID, Invoice_StatusEnum Status, int IncassoID = -1)
        {
            DBAccess db = new DBAccess();

            InvoiceHeader c = new InvoiceHeader(ID);

            db.AddInt("ID", ID);
            db.AddInt("Status", System.Convert.ToInt32(Status));
            if (IncassoID > 0)
            {
                db.AddInt("IncassoID", IncassoID);
            }
            AddParmsStandard(db, c);

            int retval = db.ExecuteNonQuery(_SQLSetStatus);

            AddLog(Status: "InvoiceHeader", Logtext: string.Format("SetStatus InvoiceHeader: ID:{0} Status:{1}", c.ID, c.StatusText), Metode: "SetStatus");
            return(retval);
        }
コード例 #7
0
        public static InvoiceHeader GetInvoice(int ID)
        {
            DBAccess      db = new DBAccess();
            InvoiceHeader c  = new InvoiceHeader();

            db.AddInt("ID", ID);
            SqlDataReader dr = (SqlDataReader)(db.ExecuteReader(_SQLSelectOne));

            if (dr.HasRows)
            {
                while (dr.Read())
                {
                    Populate(dr, c);
                }
                dr.Close();
                return(c);
            }
            else
            {
                dr.Close();
                return(c); //Nothing
            }
        }
コード例 #8
0
        public static int Insert(InvoiceHeader c)
        {
            DBAccess db = new DBAccess();

            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)
            {
                c.ID = Funktioner.ToInt(objParam.Value);
                AddLog(Status: "InvoiceHeader", Logtext: string.Format("Create InvoiceHeader: ID:{0}", c.ID), Metode: "Insert");
                return(c.ID); //Integer.Parse(objParam.Value.ToString)
            }
            else
            {
                AddLog(Status: "InvoiceHeader", Logtext: string.Format("Failure to Create InvoiceHeader:"), logtype: LogTypeEnum.Error, Metode: "Insert");
                return(-1);
            }
        }
コード例 #9
0
        private static void Populate(SqlDataReader dr, InvoiceHeader c)
        {
            PopulateStandard(dr, c);
            var with_1 = c;

            with_1.Status    = (RescueTekniq.BOL.Invoice_StatusEnum)(dr.DBtoInt("Status"));               //	int '
            with_1.CompanyID = System.Convert.ToInt32(dr.DBtoInt("CompanyID"));                           //	int '

            with_1.InvoiceDate  = System.Convert.ToDateTime(dr.DBtoDate("InvoiceDate"));                  //	datetime '
            with_1.PaymentID    = System.Convert.ToInt32(dr.DBtoInt("PaymentID"));                        //	int '
            with_1.PaymentTerms = dr.DBtoString("PaymentTerms");                                          //	nvarchar(50) '
            with_1.PaymentDate  = System.Convert.ToDateTime(dr.DBtoDate("PaymentDate"));                  //	datetime '

            with_1.ResponsibleID   = System.Convert.ToInt32(dr.DBtoInt("ResponsibleID"));                 //	int '
            with_1.ResponsibleName = dr.DBtoString("ResponsibleName");                                    //	nvarchar(50) '
            with_1.ResponsibleGUID = dr.DBtoGuid("ResponsibleGUID");                                      //	uniqueidentifier '

            with_1.ContactName  = dr.DBtoString("ContactName");                                           //	nvarchar(50) '
            with_1.ContactEmail = dr.DBtoString("ContactEmail");                                          //	nvarchar(250) '
            with_1.Notes        = dr.DBtoString("Notes");                                                 //	nvarchar(max) '

            with_1.InvoiceEANno    = dr.DBtoString("InvoiceEANno");                                       //	nvarchar(15) '
            with_1.InvoiceName     = dr.DBtoString("InvoiceName");                                        //	nvarchar(100) '
            with_1.InvoiceAddress1 = dr.DBtoString("InvoiceAddress1");                                    //	nvarchar(100) '
            with_1.InvoiceAddress2 = dr.DBtoString("InvoiceAddress2");                                    //	nvarchar(100) '
            with_1.InvoiceZipCode  = dr.DBtoString("InvoiceZipCode");                                     //	nvarchar(50) '
            with_1.InvoiceCity     = dr.DBtoString("InvoiceCity");                                        //	nvarchar(50) '
            with_1.InvoiceState    = dr.DBtoString("InvoiceState");                                       //	nvarchar(50) '
            with_1.InvoiceCountry  = dr.DBtoString("InvoiceCountry");                                     //	nvarchar(50) '
            with_1.InvoiceAtt      = dr.DBtoString("InvoiceAtt");                                         //	nvarchar(50) '
            with_1.InvoiceRef      = dr.DBtoString("InvoiceRef");                                         //	nvarchar(50) '

            with_1.DeleveryEANno    = dr.DBtoString("DeleveryEANno");                                     //	nvarchar(15) '
            with_1.DeleveryName     = dr.DBtoString("DeleveryName");                                      //	nvarchar(100) '
            with_1.DeleveryAddress1 = dr.DBtoString("DeleveryAddress1");                                  //	nvarchar(100) '
            with_1.DeleveryAddress2 = dr.DBtoString("DeleveryAddress2");                                  //	nvarchar(100) '
            with_1.DeleveryZipCode  = dr.DBtoString("DeleveryZipCode");                                   //	nvarchar(50) '
            with_1.DeleveryCity     = dr.DBtoString("DeleveryCity");                                      //	nvarchar(50) '
            with_1.DeleveryState    = dr.DBtoString("DeleveryState");                                     //	nvarchar(50) '
            with_1.DeleveryCountry  = dr.DBtoString("DeleveryCountry");                                   //	nvarchar(50) '
            with_1.DeleveryAtt      = dr.DBtoString("DeleveryAtt");                                       //	nvarchar(50) '
            with_1.DeleveryRef      = dr.DBtoString("DeleveryRef");                                       //	nvarchar(50) '

            with_1.InvoiceLines        = System.Convert.ToInt32(dr.DBtoInt("InvoiceLines"));              //	int '
            with_1.InvoiceLineItems    = System.Convert.ToInt32(dr.DBtoInt("InvoiceLineItems"));          //	int '
            with_1.InvoiceLinesTotal   = System.Convert.ToDecimal(dr.DBtoDecimal("InvoiceLinesTotal"));   //	float '
            with_1.InvoiceTransport    = System.Convert.ToDecimal(dr.DBtoDecimal("InvoiceTransport"));    //	float '
            with_1.InvoiceTotal        = System.Convert.ToDecimal(dr.DBtoDecimal("InvoiceTotal"));        //	float '
            with_1.InvoiceVAT          = System.Convert.ToDecimal(dr.DBtoDecimal("InvoiceVAT"));          //	float '
            with_1.InvoiceTotalInclVAT = System.Convert.ToDecimal(dr.DBtoDecimal("InvoiceTotalInclVAT")); //	float '

            with_1.Paid     = dr.DBtoBit("Paid");                                                         //	bit '
            with_1.PaidDate = System.Convert.ToDateTime(dr.DBtoDate("PaidDate"));                         //	datetime '

            with_1.OrderNo      = dr.DBtoString("OrderNo");                                               //	nvarchar(50) '
            with_1.YourRef      = dr.DBtoString("YourRef");                                               //	nvarchar(50) '
            with_1.CreditnoteID = dr.DBtoInteger("CreditnoteID");

            with_1.VATfree    = dr.DBtoBoolean("VATfree");
            with_1.EANInvoice = System.Convert.ToBoolean(dr.DBtoBoolean("EANInvoice"));

            with_1.IncassoID = System.Convert.ToInt32(dr.DBtoInt("IncassoID"));
            if (with_1.IncassoID < 1)
            {
                with_1.IncassoID = -1;
            }
        }
コード例 #10
0
        private static void AddParms(ref DBAccess db, InvoiceHeader c)
        {
            db.AddInt("Status", (System.Int32)c.Status);
            db.AddInt("CompanyID", c.CompanyID);
            db.AddDateTime("InvoiceDate", c.InvoiceDate);

            db.AddInt("PaymentID", c.PaymentID);
            db.AddNVarChar("PaymentTerms", c.PaymentTerms, 50);
            db.AddDateTime("PaymentDate", c.PaymentDate);

            db.AddInt("ResponsibleID", c.ResponsibleID);
            db.AddNVarChar("ResponsibleName", c.ResponsibleName, 50);
            db.AddGuid("ResponsibleGUID", c.ResponsibleGUID);

            db.AddNVarChar("ContactName", c.ContactName, 50);
            db.AddNVarChar("ContactEmail", c.ContactEmail, 250);

            db.AddNVarChar("Notes", c.Notes, -1);

            db.AddNVarChar("InvoiceEANno", c.InvoiceEANno, 15);
            db.AddNVarChar("InvoiceName", c.InvoiceName, 100);
            db.AddNVarChar("InvoiceAddress1", c.InvoiceAddress1, 100);
            db.AddNVarChar("InvoiceAddress2", c.InvoiceAddress2, 100);
            db.AddNVarChar("InvoiceZipCode", c.InvoiceZipCode, 50);
            db.AddNVarChar("InvoiceCity", c.InvoiceCity, 50);
            db.AddNVarChar("InvoiceState", c.InvoiceState, 50);
            db.AddNVarChar("InvoiceCountry", c.InvoiceCountry, 50);
            db.AddNVarChar("InvoiceAtt", c.InvoiceAtt, 50);
            db.AddNVarChar("InvoiceRef", c.InvoiceRef, 50);

            db.AddNVarChar("DeleveryEANno", c.DeleveryEANno, 15);
            db.AddNVarChar("DeleveryName", c.DeleveryName, 100);
            db.AddNVarChar("DeleveryAddress1", c.DeleveryAddress1, 100);
            db.AddNVarChar("DeleveryAddress2", c.DeleveryAddress2, 100);
            db.AddNVarChar("DeleveryZipCode", c.DeleveryZipCode, 50);
            db.AddNVarChar("DeleveryCity", c.DeleveryCity, 50);
            db.AddNVarChar("DeleveryState", c.DeleveryState, 50);
            db.AddNVarChar("DeleveryCountry", c.DeleveryCountry, 50);
            db.AddNVarChar("DeleveryAtt", c.DeleveryAtt, 50);
            db.AddNVarChar("DeleveryRef", c.DeleveryRef, 50);

            db.AddInt("InvoiceLines", c.InvoiceLines);
            db.AddInt("InvoiceLineItems", c.InvoiceLineItems);

            db.AddDecimal("InvoiceLinesTotal", c.InvoiceLinesTotal);
            db.AddDecimal("InvoiceTransport", c.InvoiceTransport);
            db.AddDecimal("InvoiceTotal", c.InvoiceTotal);
            db.AddDecimal("InvoiceVAT", c.InvoiceVAT);
            db.AddDecimal("InvoiceTotalInclVAT", c.InvoiceTotalInclVAT);

            db.AddBit("Paid", c.Paid);
            db.AddDateTime("PaidDate", c.PaidDate);

            db.AddNVarChar("OrderNo", c.OrderNo, 50);
            db.AddNVarChar("YourRef", c.YourRef, 50);
            db.AddInt("CreditnoteID", c.CreditnoteID);

            db.AddBoolean("VATfree", c.VATfree);
            db.AddBoolean("EANInvoice", c.EANInvoice);

            db.AddInt("IncassoID", c.IncassoID);

            AddParmsStandard(db, c);
        }
コード例 #11
0
 public static int SetPaid(InvoiceHeader ih)
 {
     return(SetPaid(ih.ID, ih.PaidDate));
 }
コード例 #12
0
 public static int SetStatus(InvoiceHeader ih)
 {
     return(SetStatus(ih.ID, ih.Status, ih.IncassoID));
 }
コード例 #13
0
 public static int Purge(InvoiceHeader c)
 {
     return(Purge(c.ID));
 }