private void but_ok_Click(object sender, EventArgs e)
        {
            if (tb_name.Text.Trim() == "")
            {
                MessageBox.Show(PromptMessageXmlHelper.Instance.GetPromptMessage("fillname", EnumPromptMessage.warning, new string[] { "供应商" }), "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            if (this.cb_type.Text == "")
            {
                MessageBox.Show(PromptMessageXmlHelper.Instance.GetPromptMessage("filltype", EnumPromptMessage.warning, new string[] { "供应商" }), "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            //如果价格不为null,则表示需要验证输入的值是否正确
            if (!string.IsNullOrEmpty(tb_tele.Text))
            {
                //如果用户输入的值不为正整数,则提示用户
                if (!CnasUtilityTools.IsNumeric(tb_tele.Text))
                {
                    MessageBox.Show(PromptMessageXmlHelper.Instance.GetPromptMessage("inputformat", EnumPromptMessage.warning, new string[] { "电话", "130****1234" }), "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
            }
            if (!string.IsNullOrEmpty(tb_postcode.Text))
            {
                //如果用户输入的值不为正整数,则提示用户
                if (!CnasUtilityTools.IsNumeric(tb_postcode.Text))
                {
                    MessageBox.Show(PromptMessageXmlHelper.Instance.GetPromptMessage("inputformat", EnumPromptMessage.warning, new string[] { "邮政编号", "520000" }), "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
            }


            if (!string.IsNullOrEmpty(tb_email.Text))
            {
                //如果用户输入的值不为邮箱,则提示用户
                if (!CnasUtilityTools.IsEmail(tb_email.Text))
                {
                    MessageBox.Show(PromptMessageXmlHelper.Instance.GetPromptMessage("inputformat", EnumPromptMessage.warning, new string[] { "邮箱", "*****@*****.**" }), "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
            }

            if (!string.IsNullOrEmpty(tb_website.Text))
            {
                //如果用户输入的值不为网址,则提示用户
                if (!CnasUtilityTools.IsWeb(tb_website.Text))
                {
                    MessageBox.Show(PromptMessageXmlHelper.Instance.GetPromptMessage("inputformat", EnumPromptMessage.warning, new string[] { "网址", "http://www.baidu.com" }), "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
            }

            try
            {
                CnasRemotCall reCnasRemotCall = new CnasRemotCall();
                DataTable     getdt           = reCnasRemotCall.RemotInterface.SelectData("HCS-vender-sec002", null); //31
                if (Strselectid == "")                                                                                //增加
                {
                    #region 判断名字是否存在

                    if (getdt != null)
                    {
                        int ii = getdt.Rows.Count;
                        if (ii <= 0)
                        {
                            return;
                        }
                        for (int i = 0; i < ii; i++)
                        {
                            if (getdt.Rows[i]["v_name"].ToString().Trim() != null)
                            {
                                if (tb_name.Text.Trim().ToString() == getdt.Rows[i]["v_name"].ToString().Trim())
                                {
                                    MessageBox.Show(PromptMessageXmlHelper.Instance.GetPromptMessage("namerepetition", EnumPromptMessage.warning, new string[] { "供应商" }), "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                    return;
                                }
                            }
                        }
                    }
                    #endregion
                    SortedList sltmp   = new SortedList();
                    SortedList sltmp01 = new SortedList();
                    sltmp.Add(1, tb_name.Text.Trim());
                    sltmp.Add(2, tb_contact.Text.Trim());
                    sltmp.Add(3, tb_address.Text.Trim());
                    sltmp.Add(4, sl_type[cb_type.Text.Trim()].ToString());

                    sltmp.Add(5, tb_tele.Text.Trim());

                    sltmp.Add(6, tb_postcode.Text.Trim());
                    sltmp.Add(7, tb_email.Text.Trim());
                    sltmp.Add(8, tb_website.Text.Trim());
                    sltmp.Add(9, "");
                    if (chb_insvender.Checked == true)
                    {
                        sltmp.Add(10, "1");
                    }
                    else
                    {
                        sltmp.Add(10, "0");
                    }
                    sltmp01.Add(1, sltmp);
                    type02 = sl_type[cb_type.Text.Trim()].ToString();


                    //CnasRemotCall reCnasRemotCall = new CnasRemotCall();
                    string strtmp = reCnasRemotCall.RemotInterface.CheckUPData(1, "HCS-vender-add001", sltmp01, null);
                    int    recint = reCnasRemotCall.RemotInterface.UPData(1, "HCS-vender-add001", sltmp01, null);
                    if (recint > -1)
                    {
                        MessageBox.Show(PromptMessageXmlHelper.Instance.GetPromptMessage("addsuccessful", EnumPromptMessage.warning, new string[] { "供应商" }), "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        this.Close();
                    }
                }
                else//修改
                {
                    #region 判断名字是否存在
                    if (this.tb_name.Text.Trim() != Strselectname)
                    {
                        if (getdt != null)
                        {
                            int ii = getdt.Rows.Count;
                            if (ii <= 0)
                            {
                                return;
                            }
                            for (int i = 0; i < ii; i++)
                            {
                                if (getdt.Rows[i]["v_name"].ToString().Trim() != null)
                                {
                                    if (tb_name.Text.Trim().ToString() == getdt.Rows[i]["v_name"].ToString().Trim())
                                    {
                                        MessageBox.Show(PromptMessageXmlHelper.Instance.GetPromptMessage("namerepetition", EnumPromptMessage.warning, new string[] { "供应商" }), "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                        return;
                                    }
                                }
                            }
                        }
                    }

                    #endregion

                    SortedList sltmp   = new SortedList();
                    SortedList sltmp01 = new SortedList();
                    sltmp01.Add(1, tb_name.Text.Trim());
                    sltmp01.Add(2, tb_contact.Text.Trim());
                    sltmp01.Add(3, tb_address.Text.Trim());
                    sltmp01.Add(4, cb_type.Text.Substring(0, 1));
                    sltmp01.Add(5, tb_tele.Text.Trim());
                    sltmp01.Add(6, tb_postcode.Text.Trim());
                    sltmp01.Add(7, tb_email.Text.Trim());
                    sltmp01.Add(8, tb_website.Text.Trim());


                    if (chb_insvender.Checked == true)
                    {
                        sltmp01.Add(9, "1");
                    }
                    else
                    {
                        sltmp01.Add(9, "0");
                    }
                    sltmp01.Add(10, Strselectid);
                    sltmp.Add(1, sltmp01);
                    type02 = sl_type[cb_type.Text.Trim()].ToString();
                    CnasRemotCall reCnasRemotCall_01 = new CnasRemotCall();
                    //string sql = reCnasRemotCall.RemotInterface.CheckUPData(1, "HCS-vender-up001", sltmp, null);
                    int recint = reCnasRemotCall_01.RemotInterface.UPData(1, "HCS-vender-up001", sltmp, null);
                    if (recint > -1)
                    {
                        MessageBox.Show(PromptMessageXmlHelper.Instance.GetPromptMessage("updatesuccessful", EnumPromptMessage.warning, new string[] { "供应商" }), "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        this.Close();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(PromptMessageXmlHelper.Instance.GetPromptMessage("unknowerror", EnumPromptMessage.error, new string[] { ex.Message }), "错误信息", MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.Close();
            }
        }
Beispiel #2
0
        private void but_ok_Click(object sender, EventArgs e)
        {
            if (this.tb_name.Text.Trim() == "")
            {
                MessageBox.Show(PromptMessageXmlHelper.Instance.GetPromptMessage("fillname", EnumPromptMessage.warning, new string[] { "客户" }), "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            if (this.cb_type.Text == null)
            {
                MessageBox.Show(PromptMessageXmlHelper.Instance.GetPromptMessage("filltype", EnumPromptMessage.warning, new string[] { "医院" }), "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            if (!string.IsNullOrEmpty(tb_telephone.Text))
            {
                //如果用户输入的值不为正整数,则提示用户
                if (!CnasUtilityTools.IsNumeric(tb_telephone.Text))
                {
                    MessageBox.Show("联系电话输入的格式不正确,请输入正整数。", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
            }
            if (!string.IsNullOrEmpty(tb_mail.Text))
            {
                //如果用户输入的值不为邮箱,则提示用户
                if (!CnasUtilityTools.IsEmail(tb_mail.Text))
                {
                    MessageBox.Show("电子邮箱输入的格式不正确,请输入正确格式,如:[email protected]。", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
            }
            if (tb_mail.Text.Trim() == null)
            {
                tb_mail.Text = "";
            }
            if (tb_telephone.Text.Trim() == null)
            {
                tb_mail.Text = "";
            }
            if (tb_contacts.Text.Trim() == null)
            {
                tb_mail.Text = "";
            }


            CnasRemotCall reCnasRemotCall = new CnasRemotCall();
            SortedList    sttemp01        = new SortedList();

            sttemp01.Add(1, CnasBaseData.SystemID);
            DataTable getdt = reCnasRemotCall.RemotInterface.SelectData("HCS-customer-sec001", sttemp01);

            try
            {
                if (Strselectid == "")//insert data
                {
                    #region 判断名字是否存在
                    //39
                    if (getdt != null)
                    {
                        int ii = getdt.Rows.Count;
                        if (ii <= 0)
                        {
                            return;
                        }
                        for (int i = 0; i < ii; i++)
                        {
                            if (getdt.Rows[i]["cu_name"].ToString().Trim() != null)
                            {
                                if (tb_name.Text.Trim().ToString() == getdt.Rows[i]["cu_name"].ToString().Trim())
                                {
                                    MessageBox.Show(PromptMessageXmlHelper.Instance.GetPromptMessage("namerepetition", EnumPromptMessage.warning, new string[] { "医院" }), "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                    return;
                                }
                            }
                        }
                    }
                    #endregion

                    SortedList sltmp   = new SortedList();
                    SortedList sltmp01 = new SortedList();
                    sltmp01.Add(1, tb_name.Text.Trim());
                    sltmp01.Add(2, tb_barcode.Text.Trim());
                    sltmp01.Add(3, tb_address.Text.Trim());
                    sltmp01.Add(4, cb_type.Text.Trim().Substring(0, 1));
                    sltmp01.Add(5, tb_contacts.Text.Trim());
                    sltmp01.Add(6, tb_telephone.Text.Trim());
                    sltmp01.Add(7, tb_mail.Text.Trim());
                    sltmp01.Add(8, CnasBaseData.SystemID);

                    sltmp.Add(1, sltmp01);

                    //string str = reCnasRemotCall.RemotInterface.CheckUPData(1, "HCS-customer-add001", sltmp, null);
                    int recint = reCnasRemotCall.RemotInterface.UPData(1, "HCS-customer-add001", sltmp, null);
                    if (recint > -1)
                    {
                        MessageBox.Show(PromptMessageXmlHelper.Instance.GetPromptMessage("addsuccessful", EnumPromptMessage.warning, new string[] { "客户" }), "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);

                        this.Close();
                    }
                }
                else//update date
                {
                    #region 判断名字是否存在

                    if (this.tb_name.Text.Trim() != Strselectname)
                    {
                        if (getdt != null)
                        {
                            int ii = getdt.Rows.Count;
                            if (ii <= 0)
                            {
                                return;
                            }
                            for (int i = 0; i < ii; i++)
                            {
                                if (getdt.Rows[i]["cu_name"].ToString().Trim() != null)
                                {
                                    if (tb_name.Text.Trim().ToString() == getdt.Rows[i]["cu_name"].ToString().Trim())
                                    {
                                        MessageBox.Show(PromptMessageXmlHelper.Instance.GetPromptMessage("namerepetition", EnumPromptMessage.warning, new string[] { "医院" }), "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                        return;
                                    }
                                }
                            }
                        }
                    }


                    #endregion
                    SortedList sltmp   = new SortedList();
                    SortedList sltmp01 = new SortedList();
                    sltmp01.Add(1, tb_name.Text.Trim());
                    sltmp01.Add(2, tb_address.Text.Trim());
                    sltmp01.Add(3, cb_type.Text.Trim().Substring(0, 1));
                    sltmp01.Add(4, tb_contacts.Text.Trim());
                    sltmp01.Add(5, tb_telephone.Text.Trim());
                    sltmp01.Add(6, tb_mail.Text.Trim());
                    sltmp01.Add(7, Strselectid);
                    sltmp.Add(1, sltmp01);
                    //CnasRemotCall reCnasRemotCall = new CnasRemotCall();
                    string str    = reCnasRemotCall.RemotInterface.CheckUPData(1, "HCS-customer-up001", sltmp, null);
                    int    recint = reCnasRemotCall.RemotInterface.UPData(1, "HCS-customer-up001", sltmp, null);
                    if (recint > -1)
                    {
                        MessageBox.Show(PromptMessageXmlHelper.Instance.GetPromptMessage("updatesuccessful", EnumPromptMessage.warning, new string[] { "客户" }), "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);

                        this.Close();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(PromptMessageXmlHelper.Instance.GetPromptMessage("unknowerror", EnumPromptMessage.warning, new string[] { ex.Message }), "错误信息", MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.Close();
            }
        }