Example #1
0
        private void button4_Click(object sender, EventArgs e)
        {
            if (dataGridView1.CurrentCell == null)
            {
                return;
            };

            int sltRow = dataGridView1.CurrentCell.RowIndex;

            string strASts = dataGridView1.Rows[sltRow].Cells["注册状态"].Value.ToString();
            string strSSts = dataGridView1.Rows[sltRow].Cells["启用状态"].Value.ToString();


            if (strSSts == "未启用") {
                if (strASts == "已注册")
                {
                    //代码

                    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();

                    try
                    {
                        Dxt.LinkWS LinkWs = new Dxt.LinkWS();
                        int ReS = LinkWs.UnReg(CorpID.Trim(), Pwd.Trim());
                        if (ReS == 0)
                        {

                            string strSQL = "AStatus = 0 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("网络错误,无法连接到服务器!");
                    }
                    finally
                    {
                        loadData();
                    }

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