Ejemplo n.º 1
0
        private void button3_Click(object sender, EventArgs e)
        {

            if (dataGridView1.CurrentCell == null) {
                return;
            };

            int sltRow = dataGridView1.CurrentCell.RowIndex;

            string strStatus = dataGridView1.Rows[sltRow].Cells["注册状态"].Value.ToString();

            if (strStatus == "未注册") {
                //获取数据

                string AID = dataGridView1.Rows[sltRow].Cells["AID"].Value.ToString();  //主键

                string CorpID = dataGridView1.Rows[sltRow].Cells["企业号"].Value.ToString();
                string Pwd = dataGridView1.Rows[sltRow].Cells[3].Value.ToString();  //密码
                string CorpName = dataGridView1.Rows[sltRow].Cells["公司名称"].Value.ToString();
                string LinkMan = dataGridView1.Rows[sltRow].Cells["联系人"].Value.ToString();
                string Tel = dataGridView1.Rows[sltRow].Cells["联系电话"].Value.ToString();
                string Mobile = dataGridView1.Rows[sltRow].Cells["移动电话"].Value.ToString();
                string Email = dataGridView1.Rows[sltRow].Cells["邮箱"].Value.ToString();
                string Memo = dataGridView1.Rows[sltRow].Cells["备注"].Value.ToString();

                //调用webServer
                Dxt.LinkWS LinkWs = new Dxt.LinkWS();

                int ReS = LinkWs.Reg(CorpID.Trim(), Pwd.Trim(), CorpName.Trim(), LinkMan.Trim(), Tel.Trim(), Mobile.Trim(), Email.Trim(), Memo.Trim());

                try
                {
                    if (ReS == 0)
                    {

                        string strSQL = "AStatus = 1 WHERE AID = " + AID;
                        bool bRst = DBconn.Update("[dbo].[CFG_Account]", strSQL);

                        MessageBox.Show("注册成功");
                    }
                    else if (ReS == -1)
                    {
                        MessageBox.Show("帐号已经注册,请先注销!");
                    }
                    else if (ReS == -2)
                    {
                        MessageBox.Show("其他错误!");
                    }
                    else if (ReS == -3)
                    {
                        MessageBox.Show("帐号密码不匹配!");
                    }
                }
                catch (System.Net.WebException WebExcp)
                {
                    MessageBox.Show("网络错误,无法连接到服务器!");
                    throw;
                }
                finally
                {
                    loadData();
                }

            } else {
                MessageBox.Show("请检查注册状态","警告信息", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            };
        }