Exemplo n.º 1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(FishEntity.CustomerOfCompanyEntity model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update t_customerofcompany set ");
            //#warning 系统发现缺少更新的字段,请手工确认如此更新是否正确!
            strSql.Append("id=@id,");
            strSql.Append("companyid=@companyid,");
            strSql.Append("customerid=@customerid");
            strSql.Append(" where id=@id");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@id",         MySqlDbType.Int32, 11),
                new MySqlParameter("@companyid",  MySqlDbType.Int32, 11),
                new MySqlParameter("@customerid", MySqlDbType.Int32, 11)
            };
            parameters[0].Value = model.id;
            parameters[1].Value = model.companyid;
            parameters[2].Value = model.customerid;

            int rows = MySqlHelper.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(FishEntity.CustomerOfCompanyEntity model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into t_customerofcompany(");
            strSql.Append("companyid,customerid)");
            strSql.Append(" values (");
            strSql.Append("@companyid,@customerid)");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@companyid",  MySqlDbType.Int32, 11),
                new MySqlParameter("@customerid", MySqlDbType.Int32, 11)
            };
            parameters[0].Value = model.companyid;
            parameters[1].Value = model.customerid;

            int rows = MySqlHelper.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public FishEntity.CustomerOfCompanyEntity DataRowToModel(DataRow row)
 {
     FishEntity.CustomerOfCompanyEntity model = new FishEntity.CustomerOfCompanyEntity();
     if (row != null)
     {
         if (row["id"] != null && row["id"].ToString() != "")
         {
             model.id = int.Parse(row["id"].ToString());
         }
         if (row["companyid"] != null && row["companyid"].ToString() != "")
         {
             model.companyid = int.Parse(row["companyid"].ToString());
         }
         if (row["customerid"] != null && row["customerid"].ToString() != "")
         {
             model.customerid = int.Parse(row["customerid"].ToString());
         }
     }
     return(model);
 }
Exemplo n.º 4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public FishEntity.CustomerOfCompanyEntity GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select id,companyid,customerid from t_customerofcompany ");
            strSql.Append(" where id=@id");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@id", MySqlDbType.Int32)
            };
            parameters[0].Value = id;

            FishEntity.CustomerOfCompanyEntity model = new FishEntity.CustomerOfCompanyEntity();
            DataSet ds = MySqlHelper.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 5
0
        public override int Modify()
        {
            if (Check() == false)
            {
                return(0);
            }

            int sourceCompanyId = _customer.companyId;

            _customer.code = txtCode.Text;
            int companyId = 0;

            if (string.IsNullOrEmpty(txtCompany.Text) == false && txtCompany.Tag != null && txtCompany.Tag is FishEntity.CompanyEntity)
            {
                FishEntity.CompanyEntity company = txtCompany.Tag as FishEntity.CompanyEntity;
                _customer.company   = company.code;
                companyId           = company.id;
                _customer.companyId = company.id;
            }
            else
            {
                _customer.companyId = 0;
                _customer.company   = string.Empty;
            }

            _customer.currentlinkDate = dtpCurrentDate.Value;
            _customer.department      = string.Empty;
            _customer.email           = txtEmail.Text;
            _customer.modifyman       = FishEntity.Variable.User.username;
            _customer.modifytime      = DateTime.Now;
            _customer.name            = txtName.Text;
            _customer.phone1          = txtPhone1.Text;
            _customer.phone2          = txtPhone2.Text;
            _customer.phone3          = txtPhone3.Text;
            _customer.post            = txtPost.Text;
            _customer.Department1     = txtdepartment1.Text;
            _customer.qq        = txtQQ.Text;
            _customer.remark    = txtRemark.Text;
            _customer.telephone = txtTelephone.Text;
            _customer.validate  = cmbValidate.Text.Equals("有效")?1:0;
            _customer.weixin    = txtWeixin.Text;

            _customer.homeaddress   = txtHomeAddress.Text.Trim();
            _customer.officeaddress = txtOfficeAddress.Text.Trim();
            _customer.sex           = rdbMan.Checked?"男":"女";
            _customer.fox           = txtfox.Text.Trim();

            DateTime nextlinkDate;

            if (DateTime.TryParse(txtNextLinkDate.Text, out nextlinkDate))
            {
                _customer.nextlinkdate = nextlinkDate;
            }
            else
            {
                _customer.nextlinkdate = null;
            }

            FishBll.Bll.CustomerBll bll = new FishBll.Bll.CustomerBll();
            bool isOk = bll.Update(_customer);

            if (isOk)
            {
                FishBll.Bll.CustomerOfCompanyBll ccBll = new FishBll.Bll.CustomerOfCompanyBll();
                if (_customer.companyId == 0 && sourceCompanyId > 0)
                {
                    ccBll.Delete(sourceCompanyId, _customer.id);
                }
                else if (_customer.companyId > 0 && sourceCompanyId == 0)
                {
                    FishEntity.CustomerOfCompanyEntity ccEntity = new FishEntity.CustomerOfCompanyEntity();
                    ccEntity.companyid  = _customer.companyId;
                    ccEntity.customerid = _customer.id;
                    ccBll.Add(ccEntity);
                }
                else if (_customer.companyId > 0 && sourceCompanyId > 0)
                {
                    ccBll.Update(sourceCompanyId, _customer.id, _customer.companyId, _customer.id);
                }

                SaveHeaderPicture(_customer.id);

                MessageBox.Show("修改成功。");
            }
            else
            {
                MessageBox.Show("修改失败。");
            }

            return(1);
        }
Exemplo n.º 6
0
        public override void Save()
        {
            if (Check() == false)
            {
                return;
            }
            _customer      = new FishEntity.CustomerEntity();
            _customer.code = FishBll.Bll.SequenceUtil.GetCustomerSequence();
            int companyId = 0;

            if (string.IsNullOrEmpty(txtCompany.Text) == false && txtCompany.Tag != null && txtCompany.Tag is FishEntity.CompanyEntity)
            {
                FishEntity.CompanyEntity company = txtCompany.Tag as FishEntity.CompanyEntity;
                _customer.company   = company.code;
                companyId           = company.id;
                _customer.companyId = company.id;
            }
            _customer.createman       = FishEntity.Variable.User.username;
            _customer.createtime      = DateTime.Now;
            _customer.currentlinkDate = dtpCurrentDate.Value;
            _customer.department      = string.Empty;
            _customer.email           = txtEmail.Text;
            _customer.isdelete        = 0;
            _customer.modifyman       = _customer.createman;
            _customer.modifytime      = _customer.createtime;
            _customer.name            = txtName.Text;

            DateTime nextlinkdate;

            if (DateTime.TryParse(txtNextLinkDate.Text, out nextlinkdate))
            {
                _customer.nextlinkdate = DateTime.Parse(txtNextLinkDate.Text);
            }
            else
            {
                _customer.nextlinkdate = null;
            }

            _customer.phone1      = txtPhone1.Text;
            _customer.phone2      = txtPhone2.Text;
            _customer.phone3      = txtPhone3.Text;
            _customer.post        = txtPost.Text;
            _customer.Department1 = txtdepartment1.Text;
            _customer.qq          = txtQQ.Text;
            _customer.remark      = txtRemark.Text;
            _customer.telephone   = txtTelephone.Text;
            _customer.validate    = cmbValidate.Text.Equals("有效") ? 1 : 0;
            _customer.weixin      = txtWeixin.Text;

            _customer.homeaddress   = txtHomeAddress.Text.Trim();
            _customer.officeaddress = txtOfficeAddress.Text.Trim();
            _customer.sex           = rdbMan.Checked?"男":"女";
            _customer.fox           = txtfox.Text.Trim();

            FishBll.Bll.CustomerBll bll = new FishBll.Bll.CustomerBll();

            bool isok = bll.Exists(_customer.code);

            while (isok)
            {
                _customer.code = FishBll.Bll.SequenceUtil.GetCustomerSequence();
                isok           = bll.Exists(_customer.code);
            }

            bool isExistName = bll.ExistsName(_customer.name);

            if (isExistName)
            {
                MessageBox.Show("数据库中存在相同的联系人名称。");
            }

            int id = bll.Add(_customer);

            if (id > 0)
            {
                _customer.id = id;
                txtCode.Text = _customer.code;

                FishBll.Bll.CustomerOfCompanyBll ccbll = new FishBll.Bll.CustomerOfCompanyBll();
                if (false == string.IsNullOrEmpty(_customer.company))
                {
                    FishEntity.CustomerOfCompanyEntity ccEntity = new FishEntity.CustomerOfCompanyEntity();
                    ccEntity.companyid  = companyId;
                    ccEntity.customerid = _customer.id;
                    ccbll.Add(ccEntity);
                }

                SaveHeaderPicture(id);

                tmiAdd.Visible      = true;
                tmiModify.Visible   = true;
                tmiQuery.Visible    = true;
                tmiPrevious.Visible = true;
                tmiNext.Visible     = true;
                tmiSave.Visible     = false;
                tmiCancel.Visible   = false;

                MessageBox.Show("添加成功。");
            }
            else
            {
                txtCode.Text = string.Empty;
                MessageBox.Show("添加失败。");
            }
        }
Exemplo n.º 7
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(FishEntity.CustomerOfCompanyEntity model)
 {
     return(dal.Update(model));
 }
Exemplo n.º 8
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public bool Add(FishEntity.CustomerOfCompanyEntity model)
 {
     return(dal.Add(model));
 }