Пример #1
0
        private void txtcontacts_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtPayUnit.Text) == true)
            {
                MessageBox.Show("请先选择单位,再操作。");
                return;
            }
            if (txtPayUnit.Tag == null)
            {
                return;
            }

            int companyId = 0;

            int.TryParse(txtPayUnit.Tag.ToString(), out companyId);

            UIForms.FormSelectCustomer form = new UIForms.FormSelectCustomer(companyId);
            form.StartPosition = FormStartPosition.CenterParent;
            DialogResult result = form.ShowDialog();

            if (result == System.Windows.Forms.DialogResult.OK)
            {
                FishEntity.CustomerEntity customer = form.SelectedCustomer;
                if (customer != null)
                {
                    txtcontacts.Text = customer.name;
                    txtcontacts.Tag  = customer.code;
                }
            }
        }
Пример #2
0
        public override int Query()
        {
            if (_queryForm == null)
            {
                _queryForm = new UIForms.FormCustomerCondition();
                _queryForm.StartPosition = FormStartPosition.CenterParent;
                _queryForm.ShowInTaskbar = false;
            }
            if (_queryForm.ShowDialog() != System.Windows.Forms.DialogResult.OK)
            {
                return(0);
            }
            panel1.Enabled = true;
            _where         = _queryForm.GetWhereCondition; //GetQueryCondition();
            //FishBll.Bll.CustomerBll bll = new FishBll.Bll.CustomerBll();
            List <FishEntity.CustomerEntityVo> list = _bll.GetModelListVo(_where + _rolewhere + _orderBy);

            if (list == null || list.Count < 1)
            {
                _customer = null;
                return(1);
            }
            else
            {
                _customer = list[0];
                SetCustomer();
            }

            return(1);
        }
        private void txtLinkman_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtCompany.Text) == true)
            {
                MessageBox.Show("请先选择开证代理商,再操作。");
                return;
            }
            if (txtCompany.Tag == null)
            {
                return;
            }
            string companycode = string.Empty;

            companycode = txtCompany.Tag.ToString();
            UIForms.FormSelectCustomer form = new UIForms.FormSelectCustomer(companycode);
            form.StartPosition = FormStartPosition.CenterParent;
            DialogResult result = form.ShowDialog();

            if (result == System.Windows.Forms.DialogResult.OK)
            {
                FishEntity.CustomerEntity customer = form.SelectedCustomer;
                if (customer != null)
                {
                    txtLinkman.Text = customer.name;
                    txtLinkman.Tag  = customer.code;
                }
            }
        }
Пример #4
0
        protected void QueryOne(string operate, string orderBy)
        {
            string whereEx = string.Empty;

            if (string.IsNullOrEmpty(_where))
            {
                whereEx = " 1=1 ";
            }
            else
            {
                whereEx = _where;
            }

            if (_customer != null)
            {
                whereEx += " and code " + operate + _customer.code;
            }

            List <FishEntity.CustomerEntityVo> list = _bll.GetModelListVo(whereEx + _rolewhere + orderBy);

            if (list == null || list.Count < 1)
            {
                MessageBox.Show("已经没有记录了!");
                return;
            }
            this.panel1.Enabled = true;
            _customer           = list[0];

            SetCustomer();
        }
Пример #5
0
        private void txtLinkManCode_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtCompanyCode.Text) == true)
            {
                MessageBox.Show("请先选择客户,再操作。");
                return;
            }

            //FormLinkmanList form = new FormLinkmanList();
            //form.StartPosition = FormStartPosition.CenterParent;
            //DialogResult result = form.ShowDialog();
            if (txtCompanyCode.Tag == null)
            {
                return;
            }

            int companyId = 0;

            int.TryParse(txtCompanyCode.Tag.ToString(), out companyId);

            UIForms.FormSelectCustomer form = new UIForms.FormSelectCustomer(companyId);
            form.StartPosition = FormStartPosition.CenterParent;
            DialogResult result = form.ShowDialog();

            if (result == System.Windows.Forms.DialogResult.OK)
            {
                FishEntity.CustomerEntity customer = form.SelectedCustomer;
                if (customer != null)
                {
                    txtLinkMan.Text     = customer.name;
                    txtLinkManCode.Text = customer.code;
                    string temp = string.Empty;
                    if (string.IsNullOrEmpty(customer.phone1) == false)
                    {
                        temp += customer.phone1;
                    }
                    if (string.IsNullOrEmpty(customer.phone2) == false)
                    {
                        if (string.IsNullOrEmpty(temp) == false)
                        {
                            temp += ",";
                        }
                        temp += customer.phone2;
                    }
                    if (string.IsNullOrEmpty(customer.phone3) == false)
                    {
                        if (string.IsNullOrEmpty(temp) == false)
                        {
                            temp += ",";
                        }
                        temp += customer.phone3;
                    }

                    txtMobile.Text    = temp;
                    txtOfficeTel.Text = customer.telephone;
                }
            }
        }
Пример #6
0
        protected void SetCompanyData(FishEntity.CompanyEntity company)
        {
            if (company == null)
            {
                return;
            }

            txtCompanyName.Text = company.fullname;
            txtCompanyCode.Text = company.code;
            txtCompanyCode.Tag  = company.id;
            txtLevel.Text       = company.generallevel;
            txtAddress.Text     = company.address;

            txtLinkMan.Text     = string.Empty;
            txtLinkManCode.Text = string.Empty;

            txtCustomerNature.Text = company.customerproperty;
            txtSaleman.Text        = company.salesman;
            txttransportfee.Text   = company.freight.ToString();
            txtweight.Text         = company.tare.ToString();
            txtspecifacation.Text  = company.requiredproduct;
            txtQuality.Text        = company.productrequire;
            txtProducts.Text       = company.products;
            txtcompetitors.Text    = company.competitors;
            txtWeek.Text           = company.currentweekestimate.ToString();
            txtMonth.Text          = company.currentmonthestimate.ToString();

            FishBll.Bll.CustomerBll          customerBll = new FishBll.Bll.CustomerBll();
            List <FishEntity.CustomerEntity> customers   = customerBll.GetCustomerOfCompany(company.id);

            if (customers != null && customers.Count > 0)
            {
                FishEntity.CustomerEntity customer = customers.Find((i) => { return(i.flag == 1); });
                if (customer != null)
                {
                    txtLinkMan.Text     = customer.name;
                    txtLinkManCode.Text = customer.code;
                    txtLinkMan.Tag      = customer.id;
                    string phone = string.IsNullOrEmpty(customer.phone1) ? "" : customer.phone1;
                    if (!string.IsNullOrEmpty(customer.phone2))
                    {
                        phone += string.IsNullOrEmpty(phone) ? customer.phone2 : " , " + customer.phone2;
                    }
                    if (!string.IsNullOrEmpty(customer.phone3))
                    {
                        phone += string.IsNullOrEmpty(phone) ? customer.phone3 : " , " + customer.phone3;
                    }
                    txtMobile.Text    = phone;
                    txtOfficeTel.Text = customer.telephone;
                }
            }
        }
Пример #7
0
        public override int Add()
        {
            panel1.Enabled = true;
            errorProvider1.Clear();
            _customer = null;

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

            txtCode.Text        = string.Empty;
            txtCompany.Text     = string.Empty;
            txtCompanyCode.Text = string.Empty;
            txtCompanyCode.Tag  = string.Empty;
            //txtCurrentLinkDate.Text = string.Empty;
            txtEmail.Text         = string.Empty;
            txtName.Text          = string.Empty;
            txtNextLinkDate.Text  = string.Empty;
            txtPhone1.Text        = string.Empty;
            txtPhone2.Text        = string.Empty;
            txtPhone3.Text        = string.Empty;
            txtPost.Text          = string.Empty;
            txtdepartment1.Text   = string.Empty;
            txtQQ.Text            = string.Empty;
            txtRemark.Text        = string.Empty;
            txtTelephone.Text     = string.Empty;
            txtWeixin.Text        = string.Empty;
            cmbValidate.Text      = "有效";
            txtHomeAddress.Text   = string.Empty;
            txtOfficeAddress.Text = string.Empty;
            rdbMan.Checked        = true;

            pictureBox1.Image = Utility.ImageUtil.GetImage("DefaultHead.gif");

            txtfox.Text = string.Empty;

            return(1);
        }
Пример #8
0
 public void SetCustomer(FishEntity.CustomerEntity entity)
 {
     _customer = entity;
     SetCustomer();
 }
Пример #9
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("添加失败。");
            }
        }
Пример #10
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(FishEntity.CustomerEntity model)
 {
     return(dal.Update(model));
 }
Пример #11
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int  Add(FishEntity.CustomerEntity model)
 {
     return(dal.Add(model));
 }
        public override int Query()
        {
            String where = "";
            if (string.IsNullOrEmpty(txtCustomer.Text))
            {
                //MessageBox.Show("请选择客户名称");
                //return 0;
                where += " 1 = 1 ";
            }
            else
            {
                where += "customer ='" + txtCustomer.Text.Trim() + "'";
            }
            //if (cmbLinkman.SelectedValue != null && cmbLinkman.SelectedValue.ToString() != "-1")
            //{
            //    where += " and linkmancode='"+ cmbLinkman.SelectedValue.ToString() +"'";
            //}
            //string where1 = where + "  order by currentdate desc";

            string linkmanstr = "";

            foreach (Control ctl in panel2.Controls)
            {
                if (ctl is CheckBox)
                {
                    CheckBox chk = ctl as CheckBox;
                    if (chk.Checked == false)
                    {
                        continue;
                    }
                    if (chk.Tag == null)
                    {
                        continue;
                    }
                    FishEntity.CustomerEntity customer = chk.Tag as FishEntity.CustomerEntity;
                    if (customer == null)
                    {
                        continue;
                    }
                    if (string.IsNullOrEmpty(linkmanstr) == false)
                    {
                        linkmanstr += ",";
                    }
                    linkmanstr += "'" + customer.code + "'";
                }
            }
            if (string.IsNullOrEmpty(linkmanstr) == false)
            {
                where += " and linkmancode in ( " + linkmanstr + " )";
            }
            if (FishEntity.Variable.User.roletype.Equals(FishEntity.Constant.Role_SalesMan))
            {
                where += string.Format(" and createman='{0}' ", FishEntity.Variable.User.username);
            }
            else
            {
                if (cmbTheperson.SelectedValue.ToString() != " ")
                {
                    where += string.Format(" and createman='{0}' ", cmbTheperson.SelectedValue.ToString());
                }
            }
            if (cmbStatus.Text != null && cmbStatus.Text.ToString().Trim() != "")
            {
                where += " and orderstate like  '%" + cmbStatus.Text.ToString().Trim() + "%'";
            }
            //if (cmbQuote.Text != null && cmbQuote.Text.ToString().Trim() != "")
            //{
            //    where += " and LENGTH(bjqk)>11 ";
            //}
            if (cmbQuote.Text == "有报价" && cmbQuote.Text != "")
            {
                where += " and LENGTH(bjqk)>11";
            }
            else if (cmbQuote.Text == "无报价" && cmbQuote.Text != "")
            {
                where += " and LENGTH(bjqk)<=11";
            }
            if (dtsky.Text.ToString() == DateTime.Now.AddDays(1).ToString("yyyy-MM-dd"))
            {
                where += string.Format(" and currentdate>='{0}' and currentdate<='{1}' ",
                                       dtpStart.Value.ToString("yyyy-MM-dd 00:00:00"),
                                       dtpEnd.Value.ToString("yyyy-MM-dd 23:59:59"));
            }
            else
            {
                where += string.Format(" and currentdate>='{0}' and currentdate<='{1}' ", dtsky.Value.ToString("yyyy-MM-dd 00:00:00"), dtsky.Value.ToString("yyyy-MM-dd 23:59:59"));
            }


            FishBll.Bll.CallRecordsDetailBll           bll     = new FishBll.Bll.CallRecordsDetailBll();
            List <FishEntity.CallRecordDetailEntityEx> records = bll.GetRecordDetailListByWhere(where + _rolewhere);

            dataGridView1.AutoGenerateColumns = false;
            dataGridView1.DataSource          = records;
            int sum = 0;

            //for (int i = 0; i < dataGridView1.RowCount; i++)
            //{
            sum += int.Parse(this.dataGridView1.RowCount.ToString());
            // }
            txtnumber.Text = sum.ToString();
            if (records == null || records.Count < 1)
            {
                MessageBox.Show("查无数据");
            }


            return(base.Query());
        }
Пример #13
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(FishEntity.CustomerEntity model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into t_customer(");
            strSql.Append("code,name,currentlinkDate,telephone,phone1,phone2,phone3,post,department,email,qq,weixin,nextlinkdate,nextcallrecordid,validate,remark,company,createtime,createman,modifytime,modifyman,isdelete,flag,homeaddress,officeaddress,sex,fox,department1 )");
            strSql.Append(" values (");
            strSql.Append("@code,@name,@currentlinkDate,@telephone,@phone1,@phone2,@phone3,@post,@department,@email,@qq,@weixin,@nextlinkdate,@nextcallrecordid,@validate,@remark,@company,@createtime,@createman,@modifytime,@modifyman,@isdelete,@flag,@homeaddress,@officeaddress,@sex,@fox,@department1 );");
            strSql.Append("select LAST_INSERT_ID();");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@code",             MySqlDbType.VarChar,     45),
                new MySqlParameter("@name",             MySqlDbType.VarChar,     50),
                new MySqlParameter("@currentlinkDate",  MySqlDbType.Timestamp),
                new MySqlParameter("@telephone",        MySqlDbType.VarChar,     45),
                new MySqlParameter("@phone1",           MySqlDbType.VarChar,     45),
                new MySqlParameter("@phone2",           MySqlDbType.VarChar,     45),
                new MySqlParameter("@phone3",           MySqlDbType.VarChar,     45),
                new MySqlParameter("@post",             MySqlDbType.VarChar,     45),
                new MySqlParameter("@department",       MySqlDbType.VarChar,     45),
                new MySqlParameter("@email",            MySqlDbType.VarChar,     45),
                new MySqlParameter("@qq",               MySqlDbType.VarChar,     45),
                new MySqlParameter("@weixin",           MySqlDbType.VarChar,     45),
                new MySqlParameter("@nextlinkdate",     MySqlDbType.Timestamp),
                new MySqlParameter("@nextcallrecordid", MySqlDbType.Int32,       11),
                new MySqlParameter("@validate",         MySqlDbType.Int16,        1),
                new MySqlParameter("@remark",           MySqlDbType.VarChar,    200),
                new MySqlParameter("@company",          MySqlDbType.VarChar,     45),
                new MySqlParameter("@createtime",       MySqlDbType.Timestamp),
                new MySqlParameter("@createman",        MySqlDbType.VarChar,     45),
                new MySqlParameter("@modifytime",       MySqlDbType.Timestamp),
                new MySqlParameter("@modifyman",        MySqlDbType.VarChar,     45),
                new MySqlParameter("@isdelete",         MySqlDbType.Int16,        1),
                new MySqlParameter("@flag",             MySqlDbType.UInt16,       2),
                new MySqlParameter("@homeaddress",      MySqlDbType.VarChar,    255),
                new MySqlParameter("@officeaddress",    MySqlDbType.VarChar,    255),
                new MySqlParameter("@sex",              MySqlDbType.VarChar,      8),
                new MySqlParameter("@fox",              MySqlDbType.VarChar,    255),
                new MySqlParameter("@department1",      MySqlDbType.VarChar, 45)
            };
            parameters[0].Value  = model.code;
            parameters[1].Value  = model.name;
            parameters[2].Value  = model.currentlinkDate;
            parameters[3].Value  = model.telephone;
            parameters[4].Value  = model.phone1;
            parameters[5].Value  = model.phone2;
            parameters[6].Value  = model.phone3;
            parameters[7].Value  = model.post;
            parameters[8].Value  = model.department;
            parameters[9].Value  = model.email;
            parameters[10].Value = model.qq;
            parameters[11].Value = model.weixin;
            parameters[12].Value = model.nextlinkdate;
            parameters[13].Value = model.nextcallrecordid;
            parameters[14].Value = model.validate;
            parameters[15].Value = model.remark;
            parameters[16].Value = model.company;
            parameters[17].Value = model.createtime;
            parameters[18].Value = model.createman;
            parameters[19].Value = model.modifytime;
            parameters[20].Value = model.modifyman;
            parameters[21].Value = model.isdelete;
            parameters[22].Value = model.flag;
            parameters[23].Value = model.homeaddress;
            parameters[24].Value = model.officeaddress;
            parameters[25].Value = model.sex;
            parameters[26].Value = model.fox;
            parameters[27].Value = model.Department1;

            int id = MySqlHelper.ExecuteSqlReturnId(strSql.ToString(), parameters); //MySqlHelper.ExecuteSql(strSql.ToString(), parameters);

            return(id);
        }
Пример #14
0
        public FishEntity.CustomerEntity DataRowToModel(DataRow row)
        {
            FishEntity.CustomerEntity model = new FishEntity.CustomerEntity();
            if (row["id"].ToString() != "")
            {
                model.id = int.Parse(row["id"].ToString());
            }
            model.code = row["code"].ToString();
            model.name = row["name"].ToString();
            if (row["currentlinkDate"] != null && row["currentlinkDate"].ToString() != "")
            {
                model.currentlinkDate = DateTime.Parse(row["currentlinkDate"].ToString());
            }
            else
            {
                model.currentlinkDate = null;
            }
            model.telephone   = row["telephone"].ToString();
            model.phone1      = row["phone1"].ToString();
            model.phone2      = row["phone2"].ToString();
            model.phone3      = row["phone3"].ToString();
            model.post        = row["post"].ToString();
            model.Department1 = row["department1"].ToString();
            model.department  = row["department"].ToString();
            model.email       = row["email"].ToString();
            model.qq          = row["qq"].ToString();
            model.weixin      = row["weixin"].ToString();
            if (row["nextlinkdate"] != null && row["nextlinkdate"].ToString() != "")
            {
                model.nextlinkdate = DateTime.Parse(row["nextlinkdate"].ToString());
            }
            else
            {
                model.nextlinkdate = null;
            }
            if (row["validate"].ToString() != "")
            {
                model.validate = int.Parse(row["validate"].ToString());
            }
            model.remark  = row["remark"].ToString();
            model.company = row["company"].ToString();
            if (row["createtime"] != null && row["createtime"].ToString() != "")
            {
                model.createtime = DateTime.Parse(row["createtime"].ToString());
            }
            model.createman = row["createman"].ToString();
            if (row["modifytime"] != null && row["modifytime"].ToString() != "")
            {
                model.modifytime = DateTime.Parse(row["modifytime"].ToString());
            }
            model.modifyman = row["modifyman"].ToString();
            if (row["isdelete"].ToString() != "")
            {
                model.isdelete = int.Parse(row["isdelete"].ToString());
            }

            if (row["flag"].ToString() != "")
            {
                model.flag = int.Parse(row["flag"].ToString());
            }
            if (row["homeaddress"] != null)
            {
                model.homeaddress = row["homeaddress"].ToString();
            }
            if (row["officeaddress"] != null)
            {
                model.officeaddress = row["officeaddress"].ToString();
            }
            if (row["sex"] != null)
            {
                model.sex = row["sex"].ToString();
            }
            if (row["fox"] != null)
            {
                model.fox = row["fox"].ToString();
            }

            return(model);
        }
Пример #15
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public FishEntity.CustomerEntity GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select id,code,name,currentlinkDate,telephone,phone1,phone2,phone3,post,department,email,qq,weixin,nextlinkdate,nextcallrecordid,validate,remark,company,createtime,createman,modifytime,modifyman,isdelete,flag,homeaddress,officeaddress,sex,fox,department1  from t_customer ");
            strSql.Append(" where id=@id");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@id", MySqlDbType.Int32)
            };
            parameters[0].Value = id;

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["id"].ToString() != "")
                {
                    model.id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString());
                }
                model.code = ds.Tables[0].Rows[0]["code"].ToString();
                model.name = ds.Tables[0].Rows[0]["name"].ToString();
                if (ds.Tables[0].Rows[0]["currentlinkDate"] != null && ds.Tables[0].Rows[0]["currentlinkDate"].ToString() != "")
                {
                    model.currentlinkDate = DateTime.Parse(ds.Tables[0].Rows[0]["currentlinkDate"].ToString());
                }
                else
                {
                    model.currentlinkDate = null;
                }
                model.telephone   = ds.Tables[0].Rows[0]["telephone"].ToString();
                model.phone1      = ds.Tables[0].Rows[0]["phone1"].ToString();
                model.phone2      = ds.Tables[0].Rows[0]["phone2"].ToString();
                model.phone3      = ds.Tables[0].Rows[0]["phone3"].ToString();
                model.post        = ds.Tables[0].Rows[0]["post"].ToString();
                model.Department1 = ds.Tables[0].Rows[0]["department1"].ToString();
                model.department  = ds.Tables[0].Rows[0]["department"].ToString();
                model.email       = ds.Tables[0].Rows[0]["email"].ToString();
                model.qq          = ds.Tables[0].Rows[0]["qq"].ToString();
                model.weixin      = ds.Tables[0].Rows[0]["weixin"].ToString();
                if (ds.Tables[0].Rows[0]["nextlinkdate"] != null && ds.Tables[0].Rows[0]["nextlinkdate"].ToString() != "")
                {
                    model.nextlinkdate = DateTime.Parse(ds.Tables[0].Rows[0]["nextlinkdate"].ToString());
                }
                else
                {
                    model.nextlinkdate = null;
                }
                if (ds.Tables[0].Rows[0]["nextcallrecordid"] != null && ds.Tables[0].Rows[0]["nextcallrecordid"].ToString() != "")
                {
                    model.nextcallrecordid = int.Parse(ds.Tables[0].Rows[0]["nextcallrecordid"].ToString());
                }

                if (ds.Tables[0].Rows[0]["validate"].ToString() != "")
                {
                    model.validate = int.Parse(ds.Tables[0].Rows[0]["validate"].ToString());
                }
                model.remark  = ds.Tables[0].Rows[0]["remark"].ToString();
                model.company = ds.Tables[0].Rows[0]["company"].ToString();
                if (ds.Tables[0].Rows[0]["createtime"] != null && ds.Tables[0].Rows[0]["createtime"].ToString() != "")
                {
                    model.createtime = DateTime.Parse(ds.Tables[0].Rows[0]["createtime"].ToString());
                }
                model.createman = ds.Tables[0].Rows[0]["createman"].ToString();
                if (ds.Tables[0].Rows[0]["modifytime"] != null && ds.Tables[0].Rows[0]["modifytime"].ToString() != "")
                {
                    model.modifytime = DateTime.Parse(ds.Tables[0].Rows[0]["modifytime"].ToString());
                }
                model.modifyman = ds.Tables[0].Rows[0]["modifyman"].ToString();
                if (ds.Tables[0].Rows[0]["isdelete"].ToString() != "")
                {
                    model.isdelete = int.Parse(ds.Tables[0].Rows[0]["isdelete"].ToString());
                }
                if (ds.Tables[0].Rows[0]["flag"].ToString() != "")
                {
                    model.flag = int.Parse(ds.Tables[0].Rows[0]["flag"].ToString());
                }
                if (ds.Tables[0].Rows[0]["homeaddress"] != null)
                {
                    model.homeaddress = ds.Tables[0].Rows[0]["homeaddress"].ToString();
                }
                if (ds.Tables[0].Rows[0]["officeaddress"] != null)
                {
                    model.officeaddress = ds.Tables[0].Rows[0]["officeaddress"].ToString();
                }
                if (ds.Tables[0].Rows[0]["sex"] != null)
                {
                    model.sex = ds.Tables[0].Rows[0]["sex"].ToString();
                }
                if (ds.Tables[0].Rows[0]["fox"] != null)
                {
                    model.fox = ds.Tables[0].Rows[0]["fox"].ToString();
                }


                return(model);
            }
            else
            {
                return(null);
            }
        }
Пример #16
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(FishEntity.CustomerEntity model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update t_customer set ");
            strSql.Append("code=@code,");
            strSql.Append("name=@name,");
            strSql.Append("telephone=@telephone,");
            strSql.Append("phone1=@phone1,");
            strSql.Append("phone2=@phone2,");
            strSql.Append("phone3=@phone3,");
            strSql.Append("post=@post,");
            strSql.Append("department=@department,");
            strSql.Append("email=@email,");
            strSql.Append("qq=@qq,");
            strSql.Append("weixin=@weixin,");
            //strSql.Append("nextcallrecordid=@nextcallrecordid,");
            strSql.Append("validate=@validate,");
            strSql.Append("remark=@remark,");
            strSql.Append("company=@company,");
            strSql.Append("createman=@createman,");
            strSql.Append("modifyman=@modifyman,");
            strSql.Append("isdelete=@isdelete,");
            strSql.Append("flag=@flag,");
            strSql.Append("homeaddress=@homeaddress,");
            strSql.Append("officeaddress=@officeaddress,");
            strSql.Append("sex=@sex,");
            strSql.Append("fox=@fox,");
            strSql.Append("department1=@department1");
            strSql.Append(" where id=@id");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@code",          MySqlDbType.VarChar,  45),
                new MySqlParameter("@name",          MySqlDbType.VarChar,  50),
                new MySqlParameter("@telephone",     MySqlDbType.VarChar,  45),
                new MySqlParameter("@phone1",        MySqlDbType.VarChar,  45),
                new MySqlParameter("@phone2",        MySqlDbType.VarChar,  45),
                new MySqlParameter("@phone3",        MySqlDbType.VarChar,  45),
                new MySqlParameter("@post",          MySqlDbType.VarChar,  45),
                new MySqlParameter("@department",    MySqlDbType.VarChar,  45),
                new MySqlParameter("@email",         MySqlDbType.VarChar,  45),
                new MySqlParameter("@qq",            MySqlDbType.VarChar,  45),
                new MySqlParameter("@weixin",        MySqlDbType.VarChar,  45),
                //new MySqlParameter("@nextcallrecordid", MySqlDbType.Int32,11),
                new MySqlParameter("@validate",      MySqlDbType.Int16,     1),
                new MySqlParameter("@remark",        MySqlDbType.VarChar, 200),
                new MySqlParameter("@company",       MySqlDbType.VarChar,  45),
                new MySqlParameter("@createman",     MySqlDbType.VarChar,  45),
                new MySqlParameter("@modifyman",     MySqlDbType.VarChar,  45),
                new MySqlParameter("@isdelete",      MySqlDbType.Int16,     1),
                new MySqlParameter("@flag",          MySqlDbType.UInt16,    2),
                new MySqlParameter("@homeaddress",   MySqlDbType.VarChar, 255),
                new MySqlParameter("@officeaddress", MySqlDbType.VarChar, 255),
                new MySqlParameter("@sex",           MySqlDbType.VarChar,   8),
                new MySqlParameter("@fox",           MySqlDbType.VarChar, 255),
                new MySqlParameter("@department1",   MySqlDbType.VarChar,  45),
                new MySqlParameter("@id",            MySqlDbType.Int32, 11)
            };
            parameters[0].Value  = model.code;
            parameters[1].Value  = model.name;
            parameters[2].Value  = model.telephone;
            parameters[3].Value  = model.phone1;
            parameters[4].Value  = model.phone2;
            parameters[5].Value  = model.phone3;
            parameters[6].Value  = model.post;
            parameters[7].Value  = model.department;
            parameters[8].Value  = model.email;
            parameters[9].Value  = model.qq;
            parameters[10].Value = model.weixin;
            //parameters[11].Value = model.nextcallrecordid;
            parameters[11].Value = model.validate;
            parameters[12].Value = model.remark;
            parameters[13].Value = model.company;
            parameters[14].Value = model.createman;
            parameters[15].Value = model.modifyman;
            parameters[16].Value = model.isdelete;
            parameters[17].Value = model.flag;
            parameters[18].Value = model.homeaddress;
            parameters[19].Value = model.officeaddress;
            parameters[20].Value = model.sex;
            parameters[21].Value = model.fox;
            parameters[22].Value = model.Department1;
            parameters[23].Value = model.id;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }