Пример #1
0
 /// <summary>
 /// 绑定客户速查
 /// </summary>
 /// <param name="txtCustCode"></param>
 public void BindCustomer(TextChooser txtCustCode)
 {
     //设置客户编码速查
     txtCustCode.SetBindTable("tb_customer", "cust_code", "cust_name");
     txtCustCode.GetDataSourced += new TextChooser.GetDataSourceHandler(txtcCustName_GetDataSourced);
     //txtCustCode.DataBacked += new TextChooser.DataBackHandler(txtcCustName_DataBacked);
 }
Пример #2
0
 public static void CrossThreadInvoke(TextChooser t, MethodInvoker m)
 {
     if (t.InvokeRequired)
     {
         t.Invoke(m);
     }
 }
Пример #3
0
        /// <summary> 绑定配件类型名称到选择器
        /// </summary>
        /// <param name="tc"></param>
        /// <param name="sqlString"></param>
        private static void PartsType_NameBindData(TextChooser tc, string sqlString)
        {
//            sqlString = string.Format(@"select dic_name from sys_dictionaries where dic_id not in
//                                      (select parent_id from sys_dictionaries) and dic_name like '%{0}%'", tc.Text);
//            DataTable dt = CommonFuncCall.GetDataSource(sqlString);
//            tc.SetDataSource(dt);
//            if (dt != null)
//            {
//                tc.Search();
//            }
            string        dic_ids     = string.Empty;
            List <string> list_dic_id = new List <string>();

            CreateTreeViewChildNode(list_dic_id, "sys_parts_category");
            if (list_dic_id.Count > 0)
            {
                foreach (string dic_id in list_dic_id)
                {
                    dic_ids += "'" + dic_id + "',";
                }
            }
            dic_ids   = dic_ids.Trim(',');
            sqlString = string.Format(@"select dic_name from sys_dictionaries where dic_id in ({0}) and dic_name like '%{1}%'", dic_ids, tc.Text);
            DataTable dt = CommonFuncCall.GetDataSource(sqlString);

            tc.SetDataSource(dt);
            if (dt != null)
            {
                tc.Search();
            }
        }
Пример #4
0
 void txtcCustName_GetDataSourced(TextChooser tc, string sqlString)
 {
     try
     {
         if (sqlString.Contains("tb_customer"))
         {
             string fileds = "cust_name,cust_code";
             sqlString = sqlString.Replace("*", fileds);
         }
         else if (sqlString.Contains("tb_supplier"))
         {
             string fileds = "sup_code,sup_full_name";
             sqlString = sqlString.Replace("*", fileds);
         }
         DataTable dvt = CommonFuncCall.GetDataSource(sqlString);
         tc.SetDataSource(dvt);
         if (dvt != null)
         {
             tc.Search();
         }
     }
     catch (Exception ex)
     {
         HXCPcClient.GlobalStaticObj.GlobalLogService.WriteLog(ex);
     }
 }
        /// <summary>
        /// 设置速查
        /// </summary>
        /// <param name="sqlString"></param>
        void tc_GetDataSourced(TextChooser tc, string sqlString)
        {
            DataTable dvt = CommonFuncCall.GetDataSource(sqlString);

            tc.SetDataSource(dvt);
            if (dvt != null)
            {
                tc.Search();
            }
        }
Пример #6
0
        /// <summary> 绑定供应商名称到选择器
        /// </summary>
        /// <param name="tc"></param>
        /// <param name="sqlString"></param>
        private static void Sup_NameBindData(TextChooser tc, string sqlString)
        {
            DataTable dt = CommonFuncCall.GetDataSource(sqlString);

            tc.SetDataSource(dt);
            if (dt != null)
            {
                tc.Search();
            }
        }
Пример #7
0
        /// <summary>
        /// 获取查询条件
        /// </summary>
        /// <returns></returns>
        protected string GetWhere()
        {
            StringBuilder sbWhere = new StringBuilder();

            sbWhere.Append("1=1");
            foreach (Control ctr in pnlSearch.Controls)
            {
                if (ctr.Tag == null)
                {
                    continue;
                }
                if (ctr.Tag.ToString().Length == 0)
                {
                    continue;
                }
                if (ctr is TextBoxEx)
                {
                    TextBoxEx txt    = (TextBoxEx)ctr;
                    string    strTxt = txt.Caption.Trim();
                    if (strTxt.Length > 0)
                    {
                        sbWhere.AppendFormat(" and {0} like '%{1}%'", txt.Tag, strTxt);
                    }
                }
                else if (ctr is ComboBoxEx)
                {
                    ComboBoxEx cbo    = (ComboBoxEx)ctr;
                    string     strCbo = CommonCtrl.IsNullToString(cbo.SelectedValue);
                    if (strCbo.Length > 0)
                    {
                        sbWhere.AppendFormat(" and {0}='{1}'", cbo.Tag, strCbo);
                    }
                }
                else if (ctr is TextChooser)
                {
                    TextChooser txtc    = (TextChooser)ctr;
                    string      strTxtc = txtc.Text.Trim();
                    if (strTxtc.Length > 0)
                    {
                        sbWhere.AppendFormat(" and {0}='{1}'", txtc.Tag, strTxtc);
                    }
                }
                else if (ctr is DateInterval)
                {
                    DateInterval di = (DateInterval)ctr;
                    if (!string.IsNullOrEmpty(di.StartDate) && !string.IsNullOrEmpty(di.EndDate))
                    {
                        sbWhere.AppendFormat(" and {0} between {1} and {2}", di.Tag,
                                             Common.LocalDateTimeToUtcLong(Convert.ToDateTime(di.StartDate).Date),
                                             Common.LocalDateTimeToUtcLong(Convert.ToDateTime(di.EndDate).Date.AddDays(1).AddMilliseconds(-1)));
                    }
                }
            }
            return(sbWhere.ToString());
        }
Пример #8
0
        /// <summary> 绑定配件类型名称到选择器
        /// </summary>
        /// <param name="tc"></param>
        /// <param name="sqlString"></param>
        private static void PartsType_NameBindData(TextChooser tc, string sqlString)
        {
            sqlString = string.Format(@"select dic_name from sys_dictionaries where dic_id not in 
                                      (select parent_id from sys_dictionaries) and dic_name like '%{0}%'", tc.Text);
            DataTable dt = CommonFuncCall.GetDataSource(sqlString);

            tc.SetDataSource(dt);
            if (dt != null)
            {
                tc.Search();
            }
        }
Пример #9
0
        /// <summary> 供应商名称速查选择器
        /// </summary>
        /// <param name="ContorlName">控件ID</param>
        /// <param name="delDataBack">回调函数</param>
        public static void SupperNameChoose(TextChooser ContorlName, GreetingDelegate delDataBack)
        {
            string table       = "tb_supplier";
            string valueColumn = "sup_full_name";

            //设置表和显示字段
            ContorlName.SetBindTable(table, valueColumn);
            ContorlName.GetDataSourced += new TextChooser.GetDataSourceHandler(Sup_NameBindData);
            if (delDataBack != null)
            {
                ContorlName.DataBacked -= new TextChooser.DataBackHandler(delDataBack);
                ContorlName.DataBacked += new TextChooser.DataBackHandler(delDataBack);
            }
        }
Пример #10
0
        /// <summary> 配件车型名称速查选择器
        /// </summary>
        /// <param name="ContorlName">控件ID</param>
        /// <param name="delDataBack">回调函数</param>
        public static void PartsCarModelNameChoose(TextChooser ContorlName, GreetingDelegate delDataBack)
        {
            string table       = "tb_vehicle_models";
            string valueColumn = "vm_name";

            //设置表和显示字段
            ContorlName.SetBindTable(table, valueColumn);
            ContorlName.GetDataSourced += new TextChooser.GetDataSourceHandler(PartsCarModel_NameBindData);
            if (delDataBack != null)
            {
                ContorlName.DataBacked -= new TextChooser.DataBackHandler(delDataBack);
                ContorlName.DataBacked += new TextChooser.DataBackHandler(delDataBack);
            }
        }
Пример #11
0
        /// <summary> 配件类型名称速查选择器
        /// </summary>
        /// <param name="ContorlName">控件ID</param>
        /// <param name="delDataBack">回调函数</param>
        public static void PartsTypeNameChoose(TextChooser ContorlName, GreetingDelegate delDataBack)
        {
            string table       = "sys_dictionaries";
            string valueColumn = "dic_name";

            //设置表和显示字段
            ContorlName.SetBindTable(table, valueColumn);
            ContorlName.GetDataSourced += new TextChooser.GetDataSourceHandler(PartsType_NameBindData);
            if (delDataBack != null)
            {
                ContorlName.DataBacked -= new TextChooser.DataBackHandler(delDataBack);
                ContorlName.DataBacked += new TextChooser.DataBackHandler(delDataBack);
            }
        }
Пример #12
0
        /// <summary> 客户编码速查选择器
        /// </summary>
        /// <param name="ContorlName">控件ID</param>
        /// <param name="delDataBack">回调函数</param>
        public static void CusCodeChoose(TextChooser ContorlName, GreetingDelegate delDataBack)
        {
            string table         = "tb_customer";
            string displayColumn = "cust_code";
            string valueColumn   = "cust_name";

            //设置表和显示字段
            ContorlName.SetBindTable(table, displayColumn, valueColumn);
            ContorlName.GetDataSourced += new TextChooser.GetDataSourceHandler(Cus_CodeBindData);
            if (delDataBack != null)
            {
                ContorlName.DataBacked -= new TextChooser.DataBackHandler(delDataBack);
                ContorlName.DataBacked += new TextChooser.DataBackHandler(delDataBack);
            }
        }
Пример #13
0
        /// <summary>
        /// 设置速查
        /// </summary>
        /// <param name="sqlString"></param>
        void tc_GetDataSourced(TextChooser tc, string sqlString)
        {
            if (sqlString.Contains("v_vehicle"))
            {
                string fileds = string.Format(" license_plate,vin,engine_num,v_model,v_brand,v_color,turner,cust_code,cust_id,cust_name,cont_name,{0} phone ", EncryptByDB.GetDesFieldValue("cont_phone"));
                sqlString = sqlString.Replace("*", fileds);
            }
            DataTable dvt = CommonFuncCall.GetDataSource(sqlString);

            tc.SetDataSource(dvt);
            if (dvt != null)
            {
                tc.Search();
            }
        }
 /// <summary>
 /// 设置速查
 /// </summary>
 /// <param name="sqlString"></param>
 void tc_GetDataSourced(TextChooser tc, string sqlString)
 {
     try
     {
         DataTable dvt = CommonFuncCall.GetDataSource(sqlString);
         tc.SetDataSource(dvt);
         if (dvt != null)
         {
             tc.Search();
         }
     }
     catch (Exception ex)
     {
         HXCPcClient.GlobalStaticObj.GlobalLogService.WriteLog(ex);
     }
 }
Пример #15
0
 void txtcParts_GetDataSourced(TextChooser tc, string sqlString)
 {
     try
     {
         string fileds = "parts_name,ser_parts_code";
         sqlString = sqlString.Replace("*", fileds);
         DataTable dvt = CommonFuncCall.GetDataSource(sqlString);
         tc.SetDataSource(dvt);
         if (dvt != null)
         {
             tc.Search();
         }
     }
     catch (Exception ex)
     {
         HXCPcClient.GlobalStaticObj.GlobalLogService.WriteLog(ex);
     }
 }
Пример #16
0
 //清空查询
 private void btnClear_Click(object sender, EventArgs e)
 {
     foreach (Control ctr in pnlSearch.Controls)
     {
         if (ctr is TextBoxEx)
         {
             TextBoxEx txt = (TextBoxEx)ctr;
             txt.Caption = string.Empty;
         }
         else if (ctr is ComboBoxEx)
         {
             ComboBoxEx cbo = (ComboBoxEx)ctr;
             if (cbo.Items.Count > 0)
             {
                 cbo.SelectedIndex = 0;
             }
             else
             {
                 cbo.SelectedItem = null;
             }
         }
         else if (ctr is TextChooser)
         {
             TextChooser txtc = (TextChooser)ctr;
             txtc.Text = string.Empty;
             txtc.Tag  = null;
         }
         else if (ctr is CheckBox)
         {
             CheckBox cb = (CheckBox)ctr;
             cb.Checked = false;
         }
         else if (ctr is DateInterval)
         {
             DateInterval di = (DateInterval)ctr;
             di.Empty();
             di.StartDate = DateTime.Now.ToString("yyyy-MM-01");
             di.EndDate   = DateTime.Now.ToString("yyyy-MM-dd");
         }
     }
 }
Пример #17
0
 /// <summary>
 /// 清除查询面板
 /// </summary>
 /// <param name="pnlSearch">查询面板</param>
 public void ClearSearch(Panel pnlSearch)
 {
     foreach (Control ctr in pnlSearch.Controls)
     {
         if (ctr is TextBoxEx)
         {
             TextBoxEx txt = (TextBoxEx)ctr;
             txt.Caption = string.Empty;
         }
         else if (ctr is ComboBoxEx)
         {
             ComboBoxEx cbo = (ComboBoxEx)ctr;
             if (cbo.Items.Count > 0)
             {
                 cbo.SelectedIndex = 0;
             }
             else
             {
                 cbo.SelectedItem = null;
             }
         }
         else if (ctr is TextChooser)
         {
             TextChooser txtc = (TextChooser)ctr;
             txtc.Text = string.Empty;
             txtc.Tag  = null;
         }
         else if (ctr is CheckBox)
         {
             CheckBox cb = (CheckBox)ctr;
             cb.Checked = false;
         }
         else if (ctr is DateInterval)
         {
             DateInterval di = (DateInterval)ctr;
             di.Empty();
         }
     }
 }
Пример #18
0
 /// <summary>
 /// 绑定供应商速查
 /// </summary>
 /// <param name="txtcSupplier"></param>
 public void BindSupplier(TextChooser txtcSupplier)
 {
     //设置供应商编码速查
     txtcSupplier.SetBindTable("tb_supplier", "sup_code", "sup_full_name");
     txtcSupplier.GetDataSourced += new TextChooser.GetDataSourceHandler(txtcSupplier_GetDataSourced);
 }
Пример #19
0
 /// <summary>
 /// 绑定配件速查
 /// </summary>
 /// <param name="txtcParts"></param>
 public void BindParts(TextChooser txtcParts)
 {
     txtcParts.SetBindTable("tb_parts", "ser_parts_code", "parts_name");
     txtcParts.GetDataSourced += new TextChooser.GetDataSourceHandler(txtcParts_GetDataSourced);
 }
Пример #20
0
        /// <summary> 设置容器内控件替换为label
        /// </summary>
        /// <param name="cnl">容器控件</param>
        /// <param name="isCanUse">是否可用</param>
        public static void SetControlForLable(Control pControl, bool isShowButton)
        {
            int count = pControl.Controls.Count;

            for (int i = 0; i < count; i++)
            {
                var cnl = pControl.Controls[i];
                if (cnl is TextBoxEx)
                {
                    Label lable = new Label();
                    lable.AutoSize = false;
                    lable.Size     = cnl.Size;
                    //lable.Location = cnl.Location;
                    lable.Location = new System.Drawing.Point(cnl.Location.X, cnl.Location.Y + 4);
                    pControl.Controls.Add(lable);
                    lable.BringToFront();
                    TextBoxEx txt = cnl as TextBoxEx;
                    lable.Text = txt.Caption;
                    pControl.Controls.Remove(cnl);
                    i--;
                }
                if (cnl is TextChooser)
                {
                    Label lable = new Label();
                    lable.AutoSize = false;
                    lable.Size     = cnl.Size;
                    //lable.Location = cnl.Location;
                    lable.Location = new System.Drawing.Point(cnl.Location.X, cnl.Location.Y + 4);
                    pControl.Controls.Add(lable);
                    lable.BringToFront();
                    TextChooser txt = cnl as TextChooser;
                    lable.Text = txt.Text;
                    pControl.Controls.Remove(cnl);
                    i--;
                }

                if (cnl is ComboBoxEx || cnl is ComboBox)
                {
                    Label lable = new Label();
                    lable.AutoSize = false;
                    lable.Size     = cnl.Size;
                    //lable.Location = cnl.Location;
                    lable.Location = new System.Drawing.Point(cnl.Location.X, cnl.Location.Y + 4);
                    pControl.Controls.Add(lable);
                    lable.BringToFront();
                    lable.Text = cnl.Text;
                    if (cnl.Text == "全部" || cnl.Text == "请选择")
                    {
                        lable.Text = "";
                    }
                    pControl.Controls.Remove(cnl);
                    i--;
                }
                else if (cnl is TextBox || cnl is ComboBox)
                {
                    Label lable = new Label();
                    lable.AutoSize = false;
                    lable.Size     = cnl.Size;
                    //lable.Location = cnl.Location;
                    lable.Location = new System.Drawing.Point(cnl.Location.X, cnl.Location.Y + 4);
                    pControl.Controls.Add(lable);
                    lable.BringToFront();
                    lable.Text = cnl.Text;
                    pControl.Controls.Remove(cnl);
                    i--;
                }
                else if (cnl is NumericUpDown)
                {
                    Label lable = new Label();
                    lable.AutoSize = false;
                    lable.Size     = cnl.Size;
                    lable.Location = new System.Drawing.Point(cnl.Location.X, cnl.Location.Y + 4);
                    pControl.Controls.Add(lable);
                    lable.BringToFront();
                    lable.Text = cnl.Text;
                    pControl.Controls.Remove(cnl);
                    i--;
                }
                else if (cnl is ServiceStationClient.ComponentUI.DateTimePickerEx)
                {
                    Label lable = new Label();
                    lable.AutoSize = false;
                    lable.Size     = cnl.Size;
                    lable.Location = cnl.Location;
                    DateTimePickerEx dtp = cnl as DateTimePickerEx;
                    lable.Text = dtp.Value.ToString(dtp.ShowFormat);
                    pControl.Controls.Add(lable);
                    lable.BringToFront();
                    pControl.Controls.Remove(cnl);
                    i--;
                }
                else if (cnl is CheckBox)
                {
                    Label lable = new Label();
                    lable.AutoSize = false;
                    lable.Size     = cnl.Size;
                    lable.Location = cnl.Location;
                    CheckBox cb = cnl as CheckBox;
                    if (cb.Checked)
                    {
                        lable.Text = "☑" + cb.Text;
                    }
                    else
                    {
                        lable.Text = "□" + cb.Text;
                    }
                    pControl.Controls.Add(lable);
                    lable.BringToFront();
                    pControl.Controls.Remove(cnl);
                    i--;
                }
                else if (cnl is RadioButton)
                {
                    Label lable = new Label();
                    lable.AutoSize = false;
                    lable.Size     = cnl.Size;
                    lable.Location = cnl.Location;
                    RadioButton rb = cnl as RadioButton;
                    if (rb.Checked)
                    {
                        lable.Text = "☑" + rb.Text;
                    }
                    else
                    {
                        lable.Text = "□" + rb.Text;
                    }
                    pControl.Controls.Add(lable);
                    lable.BringToFront();
                    pControl.Controls.Remove(cnl);
                    i--;
                }
                else if (cnl is DateTimePicker)
                {
                    Label lable = new Label();
                    lable.AutoSize = false;
                    lable.Size     = cnl.Size;
                    lable.Location = cnl.Location;
                    DateTimePicker dtp = cnl as DateTimePicker;
                    lable.Text = dtp.Value.ToString(dtp.CustomFormat);
                    pControl.Controls.Add(lable);
                    lable.BringToFront();
                    pControl.Controls.Remove(cnl);
                    i--;
                }
                else if (cnl is Button || cnl is ServiceStationClient.ComponentUI.ButtonEx)
                {
                    cnl.Visible = isShowButton;
                    cnl.Enabled = false;
                }
                if (cnl is Label)
                {
                    if (cnl.Text == "*")
                    {
                        cnl.Visible = false;
                    }
                }
                else if (cnl is DataGridView)
                {
                    DataGridView dgv = cnl as DataGridView;
                    dgv.ReadOnly = true;
                }
                else
                {
                    if (cnl.HasChildren)
                    {
                        SetControlForLable(cnl, isShowButton);
                    }
                }
            }
        }