예제 #1
0
        public bool Save <T>(T item) where T : IContract
        {
            var result = 0;

            var customer = (Customer)(object)item;

            var connection = db.CreateConnection();

            connection.Open();

            var transaction = connection.BeginTransaction();

            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, "RegistrationNo", System.Data.DbType.String, customer.RegistrationNo);
                db.AddInParameter(savecommand, "CreditorCode", System.Data.DbType.String, customer.CreditorCode);
                db.AddInParameter(savecommand, "DebtorCode", System.Data.DbType.String, customer.DebtorCode);
                db.AddInParameter(savecommand, "RevenueAccount", System.Data.DbType.String, customer.RevenueAccount);
                db.AddInParameter(savecommand, "Status", System.Data.DbType.Boolean, customer.Status);
                db.AddInParameter(savecommand, "Remark", System.Data.DbType.String, customer.Remark);
                db.AddInParameter(savecommand, "CreditTerm", System.Data.DbType.Int16, customer.CreditTerm);
                db.AddInParameter(savecommand, "AddressID", System.Data.DbType.String, customer.AddressID);
                db.AddInParameter(savecommand, "CreatedBy", System.Data.DbType.String, customer.CreatedBy);
                db.AddInParameter(savecommand, "ModifiedBy", System.Data.DbType.String, customer.ModifiedBy);
                db.AddInParameter(savecommand, "CustomerType", System.Data.DbType.String, customer.CustomerType);


                result = db.ExecuteNonQuery(savecommand, transaction);

                if (result > 0)
                {
                    AddressDAL addressDAL = new AddressDAL();

                    customer.CustomerAddress.CreatedBy  = customer.CreatedBy;
                    customer.CustomerAddress.ModifiedBy = customer.ModifiedBy;
                    result = addressDAL.Save(customer.CustomerAddress, transaction) == true ? 1 : 0;
                }

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

            return(result > 0 ? true : false);
        }
예제 #2
0
        public bool Save <T>(T item) where T : IContract
        {
            var result = 0;

            var branch = (Branch)(object)item;

            var connection = db.CreateConnection();

            connection.Open();

            var transaction = connection.BeginTransaction();

            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);
        }
예제 #3
0
        public Address GetBankAddress(Bank bankItem)
        {
            var contactItem = new POSAccount.Contract.Address
            {
                AddressLinkID = bankItem.BankCode,
                AddressType   = "Bank"
            };

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


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

            return(currentAddress);
        }
예제 #4
0
        public Address GetDebtorAddress(Debtor debtorItem)
        {
            var contactitem = new POSAccount.Contract.Address
            {
                AddressLinkID = debtorItem.DebtorCode,
                AddressType   = "Debtor"
            };

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


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

            return(currentAddress);
        }
예제 #5
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);
        }
예제 #6
0
        public bool Save <T>(T item) where T : IContract
        {
            var result = 0;

            var debtor = (Debtor)(object)item;

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

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


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

                db.AddInParameter(savecommand, "DebtorCode", System.Data.DbType.String, debtor.DebtorCode.ToUpper() == "NEW" ? "" : debtor.DebtorCode);
                db.AddInParameter(savecommand, "DebtorName", System.Data.DbType.String, debtor.DebtorName);
                db.AddInParameter(savecommand, "RegistrationNo", System.Data.DbType.String, debtor.RegistrationNo);
                db.AddInParameter(savecommand, "VATNo", System.Data.DbType.String, debtor.VATNo == null ? "" : debtor.VATNo);
                db.AddInParameter(savecommand, "CreditTerm", System.Data.DbType.String, debtor.CreditTerm);
                db.AddInParameter(savecommand, "DebtorAccount", System.Data.DbType.String, debtor.DebtorAccount);
                db.AddInParameter(savecommand, "PaymentType", System.Data.DbType.String, debtor.PaymentType);
                db.AddInParameter(savecommand, "CreatedBy", System.Data.DbType.String, debtor.CreatedBy);
                db.AddInParameter(savecommand, "ModifiedBy", System.Data.DbType.String, debtor.ModifiedBy);
                db.AddInParameter(savecommand, "Status", System.Data.DbType.Boolean, debtor.Status);
                db.AddInParameter(savecommand, "IsAutoSendInvoice", System.Data.DbType.Boolean, debtor.IsAutoSendInvoice);
                db.AddOutParameter(savecommand, "NewDebtorCode", System.Data.DbType.String, 10);


                result = db.ExecuteNonQuery(savecommand, transaction);

                if (result > 0)
                {
                    debtor.DebtorCode = savecommand.Parameters["@NewDebtorCode"].Value.ToString();

                    AddressDAL addressDAL = new AddressDAL();
                    debtor.DebtorAddress.CreatedBy     = debtor.CreatedBy;
                    debtor.DebtorAddress.ModifiedBy    = debtor.ModifiedBy;
                    debtor.DebtorAddress.AddressLinkID = debtor.DebtorCode;
                    result = addressDAL.Save(debtor.DebtorAddress, transaction) == true ? 1 : 0;
                }

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

                throw;
            }

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