Ejemplo n.º 1
0
        public bool Save <T>(T item) where T : IContract
        {
            var result = 0;

            var branch = (Branch)(object)item;

            if (currentTransaction == null)
            {
                connection = db.CreateConnection();
                connection.Open();
            }

            var transaction = (currentTransaction == null ? connection.BeginTransaction() : currentTransaction);


            try
            {
                var savecommand = db.GetStoredProcCommand(DBRoutine.SAVEBRANCH);

                db.AddInParameter(savecommand, "BranchID", System.Data.DbType.Int16, branch.BranchID);
                db.AddInParameter(savecommand, "BranchCode", System.Data.DbType.String, branch.BranchCode);
                db.AddInParameter(savecommand, "BranchName", System.Data.DbType.String, branch.BranchName);
                db.AddInParameter(savecommand, "RegNo", System.Data.DbType.String, branch.RegNo);
                db.AddInParameter(savecommand, "IsActive", System.Data.DbType.Boolean, branch.IsActive);
                db.AddInParameter(savecommand, "CompanyCode", System.Data.DbType.String, branch.CompanyCode);

                db.AddInParameter(savecommand, "CreatedBy", System.Data.DbType.String, branch.CreatedBy);
                db.AddInParameter(savecommand, "ModifiedBy", System.Data.DbType.String, branch.ModifiedBy);


                result = db.ExecuteNonQuery(savecommand, transaction);
                if (result > 0)
                {
                    AddressDAL addressDAL = new AddressDAL();
                    branch.BranchAddress.CreatedBy     = branch.CreatedBy;
                    branch.BranchAddress.ModifiedBy    = branch.ModifiedBy;
                    branch.BranchAddress.AddressLinkID = branch.BranchCode;
                    result = addressDAL.Save(branch.BranchAddress, transaction) == true ? 1 : 0;
                }
                if (result > 0)
                {
                    transaction.Commit();
                }
                else
                {
                    transaction.Rollback();
                }
            }
            catch (Exception)
            {
                transaction.Rollback();

                throw;
            }

            return(result > 0 ? true : false);
        }
Ejemplo n.º 2
0
        public Address GetCustomerAddress(Customer companyItem)
        {
            var contactItem = new NetStock.Contract.Address
            {
                AddressLinkID = companyItem.CustomerCode,
                AddressType   = companyItem.CustomerType
            };

            var currentAddress = new AddressDAL().GetContactsByCustomer(contactItem).FirstOrDefault();

            return(currentAddress);
        }
Ejemplo n.º 3
0
        public Address GetCompanyAddress(Company companyItem)
        {
            var contactItem = new NetStock.Contract.Address
            {
                AddressLinkID = companyItem.CompanyCode,
                AddressType   = "Company"
            };

            var currentAddress = new AddressDAL().GetContactsByCustomer(contactItem).FirstOrDefault();


            //companyItem.ContactItem =  new ContactDAL().GetItem(contactItem);

            return(currentAddress);
        }
Ejemplo n.º 4
0
        public Address GetDebtorAddress(Debtor debtorItem)
        {
            var contactitem = new NetStock.Contract.Address
            {
                AddressLinkID = debtorItem.DebtorCode,
                AddressType   = "Debtor"
            };

            var currentAddress = new AddressDAL().GetContactsByCustomer(contactitem).FirstOrDefault();


            //companyItem.ContactItem =  new ContactDAL().GetItem(contactItem);

            return(currentAddress);
        }
Ejemplo n.º 5
0
        public bool Save <T>(T item) where T : IContract
        {
            var result = 0;

            var company = (Company)(object)item;

            if (currentTransaction == null)
            {
                connection = db.CreateConnection();
                connection.Open();
            }

            var transaction = (currentTransaction == null ? connection.BeginTransaction() : currentTransaction);


            try
            {
                var savecommand = db.GetStoredProcCommand(DBRoutine.SAVECOMPANY);

                db.AddInParameter(savecommand, "CompanyCode", System.Data.DbType.String, company.CompanyCode);
                db.AddInParameter(savecommand, "CompanyName", System.Data.DbType.String, company.CompanyName);
                db.AddInParameter(savecommand, "RegNo", System.Data.DbType.String, company.RegNo);
                //db.AddInParameter(savecommand, "Logo", System.Data.DbType.Object, company.Logo);
                db.AddInParameter(savecommand, "IsActive", System.Data.DbType.Boolean, company.IsActive);
                db.AddInParameter(savecommand, "CreatedBy", System.Data.DbType.String, company.CreatedBy);
                db.AddInParameter(savecommand, "ModifiedBy", System.Data.DbType.String, company.ModifiedBy);



                result = db.ExecuteNonQuery(savecommand, transaction);

                if (result > 0)
                {
                    AddressDAL addressDAL = new AddressDAL();
                    company.CompanyAddress.CreatedBy     = company.CreatedBy;
                    company.CompanyAddress.ModifiedBy    = company.ModifiedBy;
                    company.CompanyAddress.AddressLinkID = company.CompanyCode;
                    result = addressDAL.Save(company.CompanyAddress, transaction) == true ? 1 : 0;
                }



                if (result > 0)
                {
                    if (currentTransaction == null)
                    {
                        transaction.Commit();
                    }
                }
                else
                {
                    if (currentTransaction == null)
                    {
                        transaction.Rollback();
                    }
                }
            }
            catch (Exception ex)
            {
                if (currentTransaction == null)
                {
                    transaction.Rollback();
                }

                throw ex;
            }

            return(result > 0 ? true : false);
        }
Ejemplo n.º 6
0
        public bool Save <T>(T item) where T : IContract
        {
            var result = 0;

            var customer = (Customer)(object)item;

            if (currentTransaction == null)
            {
                connection = db.CreateConnection();
                connection.Open();
            }

            var transaction = (currentTransaction == null ? connection.BeginTransaction() : currentTransaction);


            try
            {
                var savecommand = db.GetStoredProcCommand(DBRoutine.SAVECUSTOMER);

                db.AddInParameter(savecommand, "CustomerCode", System.Data.DbType.String, customer.CustomerCode);
                db.AddInParameter(savecommand, "CustomerName", System.Data.DbType.String, customer.CustomerName);
                db.AddInParameter(savecommand, "NickName", System.Data.DbType.String, customer.NickName);
                db.AddInParameter(savecommand, "InterState", System.Data.DbType.String, customer.InterState);
                db.AddInParameter(savecommand, "SalesLead", System.Data.DbType.String, customer.SalesLead);
                db.AddInParameter(savecommand, "RegistrationNo", System.Data.DbType.String, customer.RegistrationNo == null ? "" : customer.RegistrationNo);
                db.AddInParameter(savecommand, "PaymentMode", System.Data.DbType.String, customer.PaymentMode == null ? "" : customer.PaymentMode);
                db.AddInParameter(savecommand, "CustomerType", System.Data.DbType.String, customer.CustomerType);
                db.AddInParameter(savecommand, "Status", System.Data.DbType.Boolean, customer.Status);
                db.AddInParameter(savecommand, "Remark", System.Data.DbType.String, customer.Remark == null ? "" : customer.Remark);
                db.AddInParameter(savecommand, "CreditTerm", System.Data.DbType.String, customer.CreditTerm == null ? "" : customer.CreditTerm);
                db.AddInParameter(savecommand, "CustomerMode", System.Data.DbType.String, customer.CustomerMode);
                db.AddInParameter(savecommand, "AddressID", System.Data.DbType.String, customer.AddressID == null ? "" : customer.AddressID);
                db.AddInParameter(savecommand, "ContactPerson", System.Data.DbType.String, customer.ContactPerson == null ? "" : customer.ContactPerson);
                db.AddInParameter(savecommand, "ContactPerson2", System.Data.DbType.String, customer.ContactPerson2 == null ? "" : customer.ContactPerson2);
                db.AddInParameter(savecommand, "CreatedBy", System.Data.DbType.String, customer.CreatedBy);
                db.AddInParameter(savecommand, "ModifiedBy", System.Data.DbType.String, customer.ModifiedBy);
                db.AddOutParameter(savecommand, "NewCustomerCode", System.Data.DbType.String, 25);



                result = db.ExecuteNonQuery(savecommand, transaction);

                if (result > 0)
                {
                    customer.CustomerCode = savecommand.Parameters["@NewCustomerCode"].Value.ToString();

                    AddressDAL addressDAL = new AddressDAL();
                    customer.CustomerAddress.CreatedBy     = customer.CreatedBy;
                    customer.CustomerAddress.ModifiedBy    = customer.ModifiedBy;
                    customer.CustomerAddress.AddressLinkID = customer.CustomerCode;
                    result = addressDAL.Save(customer.CustomerAddress, transaction) == true ? 1 : 0;
                    if (customer.CustomerProducts != null)
                    {
                        CustomerProductDAL customerProductDAL = new CustomerProductDAL();
                        customer.CustomerProducts[0].CustomerCode = customer.CustomerCode;
                        result = customerProductDAL.Save(customer.CustomerProducts[0], transaction) == true ? 1 : 0;
                    }
                }
                if (result > 0)
                {
                    if (currentTransaction == null)
                    {
                        transaction.Commit();
                    }
                }
                else
                {
                    if (currentTransaction == null)
                    {
                        transaction.Rollback();
                    }
                }
            }
            catch (Exception ex)
            {
                if (currentTransaction == null)
                {
                    transaction.Rollback();
                }

                throw ex;
            }

            return(result > 0 ? true : false);
        }
Ejemplo n.º 7
0
        public bool Save <T>(T item) where T : IContract
        {
            var result = 0;

            var creditor = (Creditor)(object)item;

            if (currentTransaction == null)
            {
                connection = db.CreateConnection();
                connection.Open();
            }

            var transaction = (currentTransaction == null ? connection.BeginTransaction() : currentTransaction);


            try
            {
                var savecommand = db.GetStoredProcCommand(DBRoutine.SAVECREDITOR);


                db.AddInParameter(savecommand, "CreditorCode", System.Data.DbType.String, creditor.CreditorCode);
                db.AddInParameter(savecommand, "CreditorName", System.Data.DbType.String, creditor.CreditorName);
                db.AddInParameter(savecommand, "RegistrationNo", System.Data.DbType.String, creditor.RegistrationNo);
                db.AddInParameter(savecommand, "VATNo", System.Data.DbType.String, creditor.VATNo == null?"":creditor.VATNo);
                db.AddInParameter(savecommand, "CreditTerm", System.Data.DbType.String, creditor.CreditTerm);
                db.AddInParameter(savecommand, "CreditorAccount", System.Data.DbType.String, creditor.CreditorAccount);
                db.AddInParameter(savecommand, "PaymentType", System.Data.DbType.String, creditor.PaymentType);
                db.AddInParameter(savecommand, "CreatedBy", System.Data.DbType.String, creditor.CreatedBy);
                db.AddInParameter(savecommand, "ModifiedBy", System.Data.DbType.String, creditor.ModifiedBy);
                db.AddInParameter(savecommand, "Status", System.Data.DbType.Boolean, creditor.Status);
                db.AddInParameter(savecommand, "IsAutoSendInvoice", System.Data.DbType.Boolean, creditor.IsAutoSendInvoice);



                result = db.ExecuteNonQuery(savecommand, transaction);

                if (result > 0)
                {
                    AddressDAL addressDAL = new AddressDAL();
                    creditor.CreditorAddress.CreatedBy     = creditor.CreatedBy;
                    creditor.CreditorAddress.ModifiedBy    = creditor.ModifiedBy;
                    creditor.CreditorAddress.AddressLinkID = creditor.CreditorCode;
                    result = addressDAL.Save(creditor.CreditorAddress, transaction) == true ? 1 : 0;
                }

                if (result > 0)
                {
                    transaction.Commit();
                }
                else
                {
                    transaction.Rollback();
                }
            }
            catch (Exception)
            {
                if (currentTransaction == null)
                {
                    transaction.Rollback();
                }

                throw;
            }

            return(result > 0 ? true : false);
        }
Ejemplo n.º 8
0
        public bool Save <T>(T item) where T : IContract
        {
            var result = 0;

            var bank = (Bank)(object)item;

            if (currentTransaction == null)
            {
                connection = db.CreateConnection();
                connection.Open();
            }

            var transaction = (currentTransaction == null ? connection.BeginTransaction() : currentTransaction);


            try
            {
                var savecommand = db.GetStoredProcCommand(DBRoutine.SAVEBANK);

                db.AddInParameter(savecommand, "BankCode", System.Data.DbType.String, bank.BankCode);
                db.AddInParameter(savecommand, "Name", System.Data.DbType.String, bank.Name);
                db.AddInParameter(savecommand, "AccountNo", System.Data.DbType.String, bank.AccountNo);
                db.AddInParameter(savecommand, "CurrencyCode", System.Data.DbType.String, bank.CurrencyCode ?? "");
                db.AddInParameter(savecommand, "BankAccount", System.Data.DbType.String, bank.BankAccount);
                db.AddInParameter(savecommand, "OverdraftLimit", System.Data.DbType.Decimal, bank.OverdraftLimit);
                db.AddInParameter(savecommand, "CurrentBalance", System.Data.DbType.Decimal, bank.CurrentBalance);
                db.AddInParameter(savecommand, "SwiftCode", System.Data.DbType.String, bank.SwiftCode ?? "");
                db.AddInParameter(savecommand, "Status", System.Data.DbType.Boolean, bank.Status);
                db.AddInParameter(savecommand, "AddressId", System.Data.DbType.String, bank.AddressId ?? "");
                db.AddInParameter(savecommand, "CreatedBy", System.Data.DbType.String, bank.CreatedBy);
                db.AddInParameter(savecommand, "ModifiedBy", System.Data.DbType.String, bank.ModifiedBy);


                result = db.ExecuteNonQuery(savecommand, transaction);

                if (result > 0)
                {
                    AddressDAL addressDAL = new AddressDAL();
                    bank.BankAddress.CreatedBy     = bank.CreatedBy;
                    bank.BankAddress.ModifiedBy    = bank.ModifiedBy;
                    bank.BankAddress.AddressLinkID = bank.BankCode;
                    result = addressDAL.Save(bank.BankAddress, transaction) == true ? 1 : 0;
                }

                if (result > 0)
                {
                    transaction.Commit();
                }
                else
                {
                    transaction.Rollback();
                }
            }
            catch (Exception)
            {
                if (currentTransaction == null)
                {
                    transaction.Rollback();
                }

                throw;
            }

            return(result > 0 ? true : false);
        }