//获取输入数据
        private BillVisa GetSaveEntity()
        {
            var entity = new BillVisa();
            if (string.IsNullOrEmpty(hidID.Value.Trim()) == false)
                entity.ID = int.Parse(hidID.Value.Trim());
            //hardcode according ddldep text
            entity.DepName = ddlDept.SelectedItem.Text;

            if (string.IsNullOrEmpty(hidDepId.Value.Trim()) == false)
                entity.DepId = int.Parse(hidDepId.Value.Trim());
            else
            {
                if (entity.DepName.Contains("Düsseldorf"))
                    entity.DepId = 1;
                else if (entity.DepName.Contains("Stuttgart"))
                    entity.DepId = 2;
                else if (entity.DepName.Contains("Maastricht") || entity.DepName.Contains("Arnhem"))
                    entity.DepId = 3;
                else if (entity.DepName.Contains("肇庆"))
                    entity.DepId = 4;
                else if (entity.DepName.Contains("Köln"))
                    entity.DepId = 5;
            }

            if (string.IsNullOrEmpty(txtDepAddress.Text.Trim()) == false)
                entity.DepAddress = txtDepAddress.Text.Trim();

            if (string.IsNullOrEmpty(txtInnerReferenceID.Text.Trim()) == false)
                entity.InnerReferenceID = txtInnerReferenceID.Text.Trim();
            if (string.IsNullOrEmpty(txtBookingDate.Text.Trim()) == false)
                entity.BookingDate = DateTime.Parse(txtBookingDate.Text.Trim());

            if (string.IsNullOrEmpty(txtCustAddress.Text.Trim()) == false)
                entity.CustAddress = txtCustAddress.Text.Trim();
            else
                entity.CustAddress = "";
            if (string.IsNullOrEmpty(txtCustTel.Text.Trim()) == false)
                entity.CustTel = txtCustTel.Text.Trim();

            entity.CustEmail = txtCustEmail.Text.Trim();
            entity.ParentCompany = txtParentCompany.Text.Trim();

            if (string.IsNullOrEmpty(txtCustName.Text.Trim()) == false)
                entity.CustName = txtCustName.Text.Trim();

            if (hidCustID.Text != "")
                entity.CustID = long.Parse(hidCustID.Text);
            else
                entity.CustID = CustSvr.GetCustIDByName(entity.CustName,
                    entity.CustAddress, entity.CustTel, entity.CustEmail,
                    base.LoginUserID, int.Parse(txtCustOwnerID.Text.Trim()), true);

            entity.Currency = "EUR";
            entity.PayMethod = ddlPayMethod.Text;
            if (!string.IsNullOrEmpty(txtPaymentDate.Text))
                entity.PayDate = DateTime.Parse(txtPaymentDate.Text);
            entity.Remark = txtRemark.Text.Trim();
            if (string.IsNullOrEmpty(txtCustCDate.Text.Trim()) == false)
                entity.CreateDate = DateTime.Parse(txtCustCDate.Text.Trim());
            if (string.IsNullOrEmpty(txtCustCUserID.Value.Trim()) == false)
                entity.CreateUserID = int.Parse(txtCustCUserID.Value.Trim());
            if (string.IsNullOrEmpty(txtCustOwnerID.Text.Trim()) == false)
                entity.CustOwnerID = int.Parse(txtCustOwnerID.Text.Trim());

            entity.Status = 'A';
            entity.ModifyDate = DateTime.Now;
            entity.ModifyUserID = base.LoginUserID;

            return entity;
        }
Exemple #2
0
        public BillVisa Save(BillVisa entity, IList <BillVisaPerson> PersonList)
        {
            if (this.dataCtx.Connection != null)
            {
                if (this.dataCtx.Connection.State == ConnectionState.Closed)
                {
                    this.dataCtx.Connection.Open();
                }
            }
            DbTransaction tran = this.dataCtx.Connection.BeginTransaction();

            dataCtx.Transaction = tran;

            try
            {
                //由BillVisaPerson的Price合计算出总价
                decimal totalAmount = 0;
                foreach (var person in PersonList)
                {
                    totalAmount += person.EmbassyFee + person.PostFee + person.ServiceFee
                                   + person.BirthCert + person.HKPass + person.VisaCenterFee;
                }
                entity.TotalAmount = totalAmount;
                //查询是否存在db
                var qry = from t in BillVisas
                          where t.ID == entity.ID
                          select t;
                var obj = qry.SingleOrDefault();
                if (obj != null)
                {
                    //对比新旧记录,增加auditlog
                    this.AddAuditLog(obj, entity);
                    this.CopyEntity(obj, entity);
                }
                else
                {
                    this.BillVisas.InsertOnSubmit(entity);
                }

                this.dataCtx.SubmitChanges();
                //-------------- Delete & Insert TicketPerson Again -------------
                this.BillVisaPersons.DeleteAllOnSubmit(this.BillVisaPersons.Where(t => t.VisaID == entity.ID).ToList());

                if (PersonList != null)
                {
                    foreach (var person in PersonList)
                    {
                        //如果是新增信息,id=0,要赋值
                        if (person.VisaID == 0)
                        {
                            person.VisaID = entity.ID;
                        }

                        //PersonAmount

                        if (person.VisaName.Trim() != "")
                        {
                            this.BillVisaPersons.InsertOnSubmit(person);
                        }
                    }
                }
                this.dataCtx.SubmitChanges();

                //------------Sync to CRMCustomerDeal-------------
                Sync2CRMCustomerDeal(entity.InnerReferenceID);

                tran.Commit();

                return(entity);
            }
            catch (Exception ex)
            {
                tran.Rollback();
                throw ex;
            }
            finally
            {
                dataCtx.Connection.Close();
            }
        }
Exemple #3
0
        private void AddAuditLog(BillVisa oldEntity, BillVisa newEntity)
        {
            string    oldOwner, newOwner;
            DataTable dtUser = base.GetUser();

            oldOwner = dtUser.Select("UserID=" + oldEntity.CustOwnerID)[0]["UserFullName"].ToString();
            newOwner = dtUser.Select("UserID=" + newEntity.CustOwnerID)[0]["UserFullName"].ToString();


            CRMAuditLog Log = new CRMAuditLog();

            Log.Action   = "SaveVisa"; //界面显示时再转成多语言 SaveCustomer,SaveDeal,SaveUser
            Log.ActionAt = DateTime.Now;
            Log.ActionBy = newEntity.ModifyUserID;
            Log.PKId     = newEntity.ID;
            string ActionLog = "";

            if (oldEntity.DepName != newEntity.DepName)
            {
                ActionLog += "部门:" + oldEntity.DepName + "=>" + newEntity.DepName + " ;";
            }
            if (oldEntity.DepAddress != newEntity.DepAddress)
            {
                ActionLog += "公司地址:" + oldEntity.DepAddress + "=>" + newEntity.DepAddress + " ;";
            }
            if (oldEntity.InnerReferenceID != newEntity.InnerReferenceID)
            {
                ActionLog += "内部预订号:" + oldEntity.InnerReferenceID + "=>" + newEntity.InnerReferenceID + " ;";
            }
            if (oldEntity.BookingDate != newEntity.BookingDate)
            {
                ActionLog += "预订日期:" + oldEntity.BookingDate + "=>" + newEntity.BookingDate + " ;";
            }

            if (oldEntity.CustID != newEntity.CustID)
            {
                ActionLog += "CustID:" + oldEntity.CustID + "=>" + newEntity.CustID + " ;";
            }

            if (oldEntity.CustName != newEntity.CustName)
            {
                ActionLog += "客户姓名:" + oldEntity.CustName + "=>" + newEntity.CustName + " ;";
            }

            if (oldEntity.CustEmail != newEntity.CustEmail)
            {
                ActionLog += "电邮:" + oldEntity.CustEmail + "=>" + newEntity.CustEmail + " ;";
            }

            if (oldEntity.CustAddress != newEntity.CustAddress)
            {
                ActionLog += "客户地址:" + oldEntity.CustAddress + "=>" + newEntity.CustAddress + " ;";
            }

            if (oldEntity.CustTel != newEntity.CustTel)
            {
                ActionLog += "电话:" + oldEntity.CustTel + "=>" + newEntity.CustTel + " ;";
            }
            if (oldEntity.CustOwnerID != newEntity.CustOwnerID)
            {
                ActionLog += "所属销售:" + oldOwner + "=>" + newOwner + " ;";
            }
            //if (oldEntity.BankAccount != newEntity.BankAccount)
            //    ActionLog += "BankAccount:" + oldEntity.BankAccount + "=>" + newEntity.BankAccount + " ;";
            //if (oldEntity.Currency != newEntity.Currency)
            //    ActionLog += "Currency:" + oldEntity.Currency + "=>" + newEntity.Currency + " ;";
            if (oldEntity.TotalAmount != newEntity.TotalAmount)
            {
                ActionLog += "总价:" + oldEntity.TotalAmount + "=>" + newEntity.TotalAmount + " ;";
            }

            if (oldEntity.Status != newEntity.Status)
            {
                ActionLog += "Status:" + oldEntity.Status + "=>" + newEntity.Status + " ;";
            }

            Log.ActionLog = ActionLog;

            this.CRMAuditLogs.InsertOnSubmit(Log);
        }
        //获取输入数据
        private BillVisa GetSaveEntity()
        {
            var entity = new BillVisa();

            if (string.IsNullOrEmpty(hidID.Value.Trim()) == false)
            {
                entity.ID = int.Parse(hidID.Value.Trim());
            }
            //hardcode according ddldep text
            entity.DepName = ddlDept.SelectedItem.Text;

            if (string.IsNullOrEmpty(hidDepId.Value.Trim()) == false)
            {
                entity.DepId = int.Parse(hidDepId.Value.Trim());
            }
            else
            {
                if (entity.DepName.Contains("Düsseldorf"))
                {
                    entity.DepId = 1;
                }
                else if (entity.DepName.Contains("Stuttgart"))
                {
                    entity.DepId = 2;
                }
                else if (entity.DepName.Contains("Maastricht") || entity.DepName.Contains("Arnhem"))
                {
                    entity.DepId = 3;
                }
                else if (entity.DepName.Contains("肇庆"))
                {
                    entity.DepId = 4;
                }
                else if (entity.DepName.Contains("Köln"))
                {
                    entity.DepId = 5;
                }
            }

            if (string.IsNullOrEmpty(txtDepAddress.Text.Trim()) == false)
            {
                entity.DepAddress = txtDepAddress.Text.Trim();
            }

            if (string.IsNullOrEmpty(txtInnerReferenceID.Text.Trim()) == false)
            {
                entity.InnerReferenceID = txtInnerReferenceID.Text.Trim();
            }
            if (string.IsNullOrEmpty(txtBookingDate.Text.Trim()) == false)
            {
                entity.BookingDate = DateTime.Parse(txtBookingDate.Text.Trim());
            }

            if (string.IsNullOrEmpty(txtCustAddress.Text.Trim()) == false)
            {
                entity.CustAddress = txtCustAddress.Text.Trim();
            }
            else
            {
                entity.CustAddress = "";
            }
            if (string.IsNullOrEmpty(txtCustTel.Text.Trim()) == false)
            {
                entity.CustTel = txtCustTel.Text.Trim();
            }

            entity.CustEmail     = txtCustEmail.Text.Trim();
            entity.ParentCompany = txtParentCompany.Text.Trim();

            if (string.IsNullOrEmpty(txtCustName.Text.Trim()) == false)
            {
                entity.CustName = txtCustName.Text.Trim();
            }

            if (hidCustID.Text != "")
            {
                entity.CustID = long.Parse(hidCustID.Text);
            }
            else
            {
                entity.CustID = CustSvr.GetCustIDByName(entity.CustName,
                                                        entity.CustAddress, entity.CustTel, entity.CustEmail,
                                                        base.LoginUserID, int.Parse(txtCustOwnerID.Text.Trim()), true);
            }


            entity.Currency  = "EUR";
            entity.PayMethod = ddlPayMethod.Text;
            if (!string.IsNullOrEmpty(txtPaymentDate.Text))
            {
                entity.PayDate = DateTime.Parse(txtPaymentDate.Text);
            }
            entity.Remark = txtRemark.Text.Trim();
            if (string.IsNullOrEmpty(txtCustCDate.Text.Trim()) == false)
            {
                entity.CreateDate = DateTime.Parse(txtCustCDate.Text.Trim());
            }
            if (string.IsNullOrEmpty(txtCustCUserID.Value.Trim()) == false)
            {
                entity.CreateUserID = int.Parse(txtCustCUserID.Value.Trim());
            }
            if (string.IsNullOrEmpty(txtCustOwnerID.Text.Trim()) == false)
            {
                entity.CustOwnerID = int.Parse(txtCustOwnerID.Text.Trim());
            }

            entity.Status       = 'A';
            entity.ModifyDate   = DateTime.Now;
            entity.ModifyUserID = base.LoginUserID;

            return(entity);
        }
Exemple #5
0
        private void AddAuditLog(BillVisa oldEntity, BillVisa newEntity)
        {
            string oldOwner, newOwner;
            DataTable dtUser = base.GetUser();
            oldOwner = dtUser.Select("UserID=" + oldEntity.CustOwnerID)[0]["UserFullName"].ToString();
            newOwner = dtUser.Select("UserID=" + newEntity.CustOwnerID)[0]["UserFullName"].ToString();

            CRMAuditLog Log = new CRMAuditLog();
            Log.Action = "SaveVisa"; //界面显示时再转成多语言 SaveCustomer,SaveDeal,SaveUser
            Log.ActionAt = DateTime.Now;
            Log.ActionBy = newEntity.ModifyUserID;
            Log.PKId = newEntity.ID;
            string ActionLog = "";

            if (oldEntity.DepName != newEntity.DepName)
                ActionLog += "部门:" + oldEntity.DepName + "=>" + newEntity.DepName + " ;";
            if (oldEntity.DepAddress != newEntity.DepAddress)
                ActionLog += "公司地址:" + oldEntity.DepAddress + "=>" + newEntity.DepAddress + " ;";
            if (oldEntity.InnerReferenceID != newEntity.InnerReferenceID)
                ActionLog += "内部预订号:" + oldEntity.InnerReferenceID + "=>" + newEntity.InnerReferenceID + " ;";
            if (oldEntity.BookingDate != newEntity.BookingDate)
                ActionLog += "预订日期:" + oldEntity.BookingDate + "=>" + newEntity.BookingDate + " ;";

            if (oldEntity.CustID != newEntity.CustID)
                ActionLog += "CustID:" + oldEntity.CustID + "=>" + newEntity.CustID + " ;";

            if (oldEntity.CustName != newEntity.CustName)
                ActionLog += "客户姓名:" + oldEntity.CustName + "=>" + newEntity.CustName + " ;";

            if (oldEntity.CustEmail != newEntity.CustEmail)
                ActionLog += "电邮:" + oldEntity.CustEmail + "=>" + newEntity.CustEmail + " ;";

            if (oldEntity.CustAddress != newEntity.CustAddress)
                ActionLog += "客户地址:" + oldEntity.CustAddress + "=>" + newEntity.CustAddress + " ;";

            if (oldEntity.CustTel != newEntity.CustTel)
                ActionLog += "电话:" + oldEntity.CustTel + "=>" + newEntity.CustTel + " ;";
            if (oldEntity.CustOwnerID != newEntity.CustOwnerID)
                ActionLog += "所属销售:" + oldOwner + "=>" + newOwner + " ;";
            //if (oldEntity.BankAccount != newEntity.BankAccount)
            //    ActionLog += "BankAccount:" + oldEntity.BankAccount + "=>" + newEntity.BankAccount + " ;";
            //if (oldEntity.Currency != newEntity.Currency)
            //    ActionLog += "Currency:" + oldEntity.Currency + "=>" + newEntity.Currency + " ;";
            if (oldEntity.TotalAmount != newEntity.TotalAmount)
                ActionLog += "总价:" + oldEntity.TotalAmount + "=>" + newEntity.TotalAmount + " ;";

            if (oldEntity.Status != newEntity.Status)
                ActionLog += "Status:" + oldEntity.Status + "=>" + newEntity.Status + " ;";

            Log.ActionLog = ActionLog;

            this.CRMAuditLogs.InsertOnSubmit(Log);
        }
Exemple #6
0
        public BillVisa Save(BillVisa entity, IList<BillVisaPerson> PersonList)
        {
            if (this.dataCtx.Connection != null)
                if (this.dataCtx.Connection.State == ConnectionState.Closed)
                    this.dataCtx.Connection.Open();
            DbTransaction tran = this.dataCtx.Connection.BeginTransaction();
            dataCtx.Transaction = tran;

            try
            {
                //由BillVisaPerson的Price合计算出总价
                decimal totalAmount = 0;
                foreach (var person in PersonList)
                {
                    totalAmount += person.EmbassyFee + person.PostFee + person.ServiceFee
                        + person.BirthCert + person.HKPass + person.VisaCenterFee;
                }
                entity.TotalAmount = totalAmount;
                //查询是否存在db
                var qry = from t in BillVisas
                          where t.ID == entity.ID
                          select t;
                var obj = qry.SingleOrDefault();
                if (obj != null)
                {
                    //对比新旧记录,增加auditlog
                    this.AddAuditLog(obj, entity);
                    this.CopyEntity(obj, entity);
                }
                else
                    this.BillVisas.InsertOnSubmit(entity);

                this.dataCtx.SubmitChanges();
                //-------------- Delete & Insert TicketPerson Again -------------
                this.BillVisaPersons.DeleteAllOnSubmit(this.BillVisaPersons.Where(t => t.VisaID == entity.ID).ToList());

                if (PersonList != null)
                {
                    foreach (var person in PersonList)
                    {
                        //如果是新增信息,id=0,要赋值
                        if (person.VisaID == 0)
                            person.VisaID = entity.ID;

                        //PersonAmount

                        if (person.VisaName.Trim() != "")
                            this.BillVisaPersons.InsertOnSubmit(person);

                    }
                }
                this.dataCtx.SubmitChanges();

                //------------Sync to CRMCustomerDeal-------------
                Sync2CRMCustomerDeal(entity.InnerReferenceID);

                tran.Commit();

                return entity;
            }
            catch (Exception ex)
            {
                tran.Rollback();
                throw ex;
            }
            finally
            {
                dataCtx.Connection.Close();
            }
        }