Ejemplo n.º 1
0
        /// <summary>
        /// 获取该供应商下所关联的所有联系人信息
        /// </summary>
        /// <param name="suppId"></param>
        /// <returns></returns>
        private void GetAllContacts(string suppId)
        {
            //string conId = string.Empty;
            //DataTable dt_contacts = new DataTable();
            //DataTable dt_base_contacts = DBHelper.GetTable("查询关联的联系人ID集合", "tr_base_contacts", "cont_id", " relation_object_id='" + suppId + "'", "", "");
            //if (dt_base_contacts != null && dt_base_contacts.Rows.Count > 0)
            //{
            //    foreach (DataRow dr in dt_base_contacts.Rows)
            //    {
            //        conId += "'" + dr["cont_id"] + "',";
            //    }
            //    conId = conId.Trim(',');
            //    gvUserInfoList.DataSource = DBHelper.GetTable("查询关联的联系人信息", "tb_contacts", "*", " cont_id in (" + conId + ")", "", "");
            //}
            string    conId            = string.Empty;
            DataTable dt_base_contacts = DBHelper.GetTable("查询关联的联系人ID集合", "tr_base_contacts", "*", " relation_object_id='" + suppId + "'", "", "");

            if (dt_base_contacts != null && dt_base_contacts.Rows.Count > 0)
            {
                isdefault        defaultModel = new isdefault();
                List <isdefault> list_default = new List <isdefault>();
                foreach (DataRow dr in dt_base_contacts.Rows)
                {
                    conId                  += "'" + dr["cont_id"] + "',";
                    defaultModel            = new isdefault();
                    defaultModel.cont_id    = dr["cont_id"].ToString();
                    defaultModel.is_default = dr["is_default"] == null || dr["is_default"].ToString() == "" ? "0" : dr["is_default"].ToString();
                    list_default.Add(defaultModel);
                }
                conId = conId.Trim(',');

                string    TableName   = string.Format(@"(select dic_name as con_post_name,tb_contacts.* from 
                                                    tb_contacts 
                                                    left join 
                                                    sys_dictionaries on 
                                                    tb_contacts.cont_post=sys_dictionaries.dic_id)
                                                     as tb_contacts");
                DataTable dt_contacts = DBHelper.GetTable("查询关联的联系人信息", TableName, string.Format("*,{0} phone,{1} tel", EncryptByDB.GetDesFieldValue("cont_phone"), EncryptByDB.GetDesFieldValue("cont_tel")), " cont_id in (" + conId + ")", "", "");
                foreach (DataRow dr in dt_contacts.Rows)
                {
                    DataGridViewRow dgvr = gvUserInfoList.Rows[gvUserInfoList.Rows.Add()];
                    dgvr.Cells["colcont_id"].Value    = dr["cont_id"];
                    dgvr.Cells["colcont_name"].Value  = dr["cont_name"];
                    dgvr.Cells["colcont_post"].Value  = dr["con_post_name"];
                    dgvr.Cells["colcont_phone"].Value = dr["phone"];
                    dgvr.Cells["colcont_tel"].Value   = dr["tel"];
                    dgvr.Cells["colremark"].Value     = dr["remark"];
                    dgvr.Cells["colcont_email"].Value = dr["cont_email"];
                    if (list_default.Count > 0)
                    {
                        dgvr.Cells["colis_default"].Value = list_default.Where(p => p.cont_id == dr["cont_id"].ToString()).First().is_default;
                    }
                    string createTime = CommonCtrl.IsNullToString(dr["cont_birthday"]);
                    if (createTime.Length > 0)
                    {
                        dgvr.Cells["colcont_birthday"].Value = DateTime.MinValue.AddTicks(Convert.ToInt64(createTime)).ToLocalTime();
                    }
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 获取该供应商下所关联的所有联系人信息
        /// </summary>
        /// <param name="suppId"></param>
        /// <returns></returns>
        private void GetAllContacts(string suppId)
        {
            //string conId = string.Empty;
            //DataTable dt_contacts = new DataTable();
            //DataTable dt_base_contacts = DBHelper.GetTable("查询关联的联系人ID集合", "tr_base_contacts", "cont_id", " relation_object_id='" + suppId + "'", "", "");
            //if (dt_base_contacts != null && dt_base_contacts.Rows.Count > 0)
            //{
            //    foreach (DataRow dr in dt_base_contacts.Rows)
            //    {
            //        conId += "'" + dr["cont_id"] + "',";
            //    }
            //    conId = conId.Trim(',');
            //    gvUserInfoList.DataSource = DBHelper.GetTable("查询关联的联系人信息", "tb_contacts", "*", " cont_id in (" + conId + ")", "", "");
            //}
            string conId = string.Empty;
            DataTable dt_base_contacts = DBHelper.GetTable("查询关联的联系人ID集合", "tr_base_contacts", "*", " relation_object_id='" + suppId + "'", "", "");
            if (dt_base_contacts != null && dt_base_contacts.Rows.Count > 0)
            {
                isdefault defaultModel = new isdefault();
                List<isdefault> list_default = new List<isdefault>();
                foreach (DataRow dr in dt_base_contacts.Rows)
                {
                    conId += "'" + dr["cont_id"] + "',";
                    defaultModel = new isdefault();
                    defaultModel.cont_id = dr["cont_id"].ToString();
                    defaultModel.is_default = dr["is_default"] == null || dr["is_default"].ToString() == "" ? "0" : dr["is_default"].ToString();
                    list_default.Add(defaultModel);
                }
                conId = conId.Trim(',');

                string TableName = string.Format(@"(select dic_name as con_post_name,tb_contacts.* from 
                                                    tb_contacts 
                                                    left join 
                                                    sys_dictionaries on 
                                                    tb_contacts.cont_post=sys_dictionaries.dic_id)
                                                     as tb_contacts");
                DataTable dt_contacts = DBHelper.GetTable("查询关联的联系人信息", TableName, string.Format("*,{0} phone,{1} tel", EncryptByDB.GetDesFieldValue("cont_phone"), EncryptByDB.GetDesFieldValue("cont_tel")), " cont_id in (" + conId + ")", "", "");
                foreach (DataRow dr in dt_contacts.Rows)
                {
                    DataGridViewRow dgvr = gvUserInfoList.Rows[gvUserInfoList.Rows.Add()];
                    dgvr.Cells["colcont_id"].Value = dr["cont_id"];
                    dgvr.Cells["colcont_name"].Value = dr["cont_name"];
                    dgvr.Cells["colcont_post"].Value = dr["con_post_name"];
                    dgvr.Cells["colcont_phone"].Value = dr["phone"];
                    dgvr.Cells["colcont_tel"].Value = dr["tel"];
                    dgvr.Cells["colremark"].Value = dr["remark"];
                    dgvr.Cells["colcont_email"].Value = dr["cont_email"];
                    if (list_default.Count > 0)
                    {
                        dgvr.Cells["colis_default"].Value = list_default.Where(p => p.cont_id == dr["cont_id"].ToString()).First().is_default;
                    }
                    string createTime = CommonCtrl.IsNullToString(dr["cont_birthday"]);
                    if (createTime.Length > 0)
                    {
                        dgvr.Cells["colcont_birthday"].Value = DateTime.MinValue.AddTicks(Convert.ToInt64(createTime)).ToLocalTime();
                    }
                }
            }
        }