예제 #1
0
        //修改用户信息,返回影响行数
        public int updateClientinfo(clientinfo c)
        {
            string sql = "update clientinfo set clientname=@clientname,telphone=@telphone,email=@email where clientid=@clientid";

            SqlParameter[] parms =
            {
                new SqlParameter("@clientid",   c.clientid),
                new SqlParameter("@clientname", c.clientname),
                new SqlParameter("@telphone",   c.telphone),
                new SqlParameter("@email",      c.email)
            };
            return(SqlHelper.ExecuteNonQuery(sql, parms));
        }
예제 #2
0
        //添加用户信息,返回受影响的行数
        public int insertClientinfo(clientinfo c)
        {
            string sql = "insert into clientinfo(clientid,clientname,telphone,email) values(@clientid,@clientname,@telphone,@email)";

            SqlParameter[] parms =
            {
                new SqlParameter("@clientid",   c.clientid),
                new SqlParameter("@clientname", c.clientname),
                new SqlParameter("@telphone",   c.telphone),
                new SqlParameter("@email",      c.email)
            };
            return(SqlHelper.ExecuteNonQuery(sql, parms));
        }
예제 #3
0
        //删除用户信息,返回影响行数。删除之前,首先查看那些关系表中是否还有该用户的相关信息。
        public int deleteClientinfo(clientinfo c)
        {
            int cl    = (int)SqlHelper.ExecuteScalar("select count(*) from clientlogin where clientid=@clientid", new SqlParameter("@clientid", c.clientid));
            int hire  = (int)SqlHelper.ExecuteScalar("select count(*) from hireinfo where clientid=@clientid", new SqlParameter("@clientid", c.clientid));
            int total = cl + hire;   //若大于0,说明其他表还有引用,不能删除

            if (total > 0)
            {
                return(-1);
            }
            else
            {
                string       sql  = "delete  from clientinfo where clientid=@clientid";
                SqlParameter parm = new SqlParameter("@clientid", c.clientid);
                return(SqlHelper.ExecuteNonQuery(sql, parm));
            }
        }
예제 #4
0
        public async Task <ActionResult> UpdateTrans([Bind(Include = "transactionID")] transaction transaction)
        {
            List <string> product     = new List <string>();
            int           nums        = (Request.QueryString.Count - 1) / 3;
            string        DateOfTrans = DateTime.Now + "";
            string        clientname  = Request.QueryString["clientname"];
            string        clientphone = Request.QueryString["clientphone"];

            for (int i = 0; i < nums; i++)
            {
                string cho           = "cho" + i;
                string chku          = "chk" + i;
                string quant         = "Quant" + i;
                Guid   DrugID        = Guid.Parse(Request.QueryString[chku]);
                Guid   transactionID = Guid.Parse(Request.QueryString[cho]);
                int    Quantity      = int.Parse(Request.QueryString[quant]);

                if (ModelState.IsValid)
                {
                    var clientinfo = new clientinfo();
                    clientinfo.clientID    = Guid.NewGuid();
                    clientinfo.clientname  = clientname;
                    clientinfo.clientphone = clientphone;
                    (await db.transactions.FindAsync(transactionID)).clientID    = clientinfo.clientID;
                    (await db.transactions.FindAsync(transactionID)).DateOfTrans = DateOfTrans;
                    (await db.transactions.FindAsync(transactionID)).Quantity    = Quantity;
                    (await db.transactions.FindAsync(transactionID)).Status      = "Sold";
                    db.Clientinfos.Add(clientinfo);
                    db.Entry(await db.transactions.FindAsync(transactionID)).State = EntityState.Modified;
                    var a = await db.SaveChangesAsync();
                }
            }
            string from = "LizMat Pharmacy";
            string to   = "+233" + clientphone.Substring(1);
            string prod = "";

            foreach (var item in product)
            {
                prod += "" + item + "";
            }
            string Total   = Request.QueryString["total"];
            string message = "Transaction Receipt. Date:" + DateOfTrans + " Products: " + prod + " Total Price: " + Total + "";

            //transaction.SendTextMessage(from, to, prod);
            return(RedirectToAction("Home2"));
        }
예제 #5
0
        private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            int clickingColumn = e.ColumnIndex;

            //点击-1—4列时,不响应
            if (clickingColumn >= -1 && clickingColumn <= 4)
            {
            }

            else
            {
                DataGridViewColumn column  = dataGridView1.Columns[e.ColumnIndex];
                string             content = (string)dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value;
                if (column.HeaderText == "删除" && content == "删除")
                {
                    if (MessageBox.Show("确定要删除该用户吗?", "删除用户", MessageBoxButtons.OKCancel) == DialogResult.OK)
                    {
                        //删除之前先查询,否则存在关系的不允许删除
                        clientinfo c = new clientinfo();
                        c.clientid = dataGridView1.Rows[e.RowIndex].Cells[1].Value.ToString();
                        int delflag = bc.delClientinfo(c);
                        if (delflag > 0)      //删除成功
                        {
                            MessageBox.Show("删除成功!");
                            dataGridView1.Rows.RemoveAt(e.RowIndex);
                        }
                        else if (delflag == 0)    //删除失败
                        {
                            MessageBox.Show("删除失败,请稍后重试!");
                        }
                        else if (delflag == -1)   //不让删除
                        {
                            MessageBox.Show("该用户还被引用,不能删除!");
                        }
                    }
                }

                else if (column.HeaderText == "编辑" && content == "编辑")
                {
                    string clientid = (string)dataGridView1.Rows[e.RowIndex].Cells[1].Value;
                    new clientUpdate(clientid).Show();
                }
            }
        }
예제 #6
0
        private void button1_Click(object sender, EventArgs e)
        {
            clientinfo c = new clientinfo();

            c.clientid   = this.label5.Text;
            c.clientname = this.textBox1.Text;
            c.telphone   = this.textBox2.Text;
            c.email      = this.textBox3.Text;

            int flagReturn = bc.upClientinfo(c);   //返回值大于0,成功;等于0,保存失败

            if (flagReturn > 0)
            {
                MessageBox.Show("保存成功!");
                this.Close();
            }
            else if (flagReturn == 0)
            {
                MessageBox.Show("保存失败,请重试");
            }
        }
예제 #7
0
        private void button2_Click(object sender, EventArgs e)
        {
            clientinfo c = new clientinfo();

            c.clientid   = this.textBox1.Text;
            c.clientname = this.textBox2.Text;
            c.telphone   = this.textBox3.Text;
            c.email      = this.textBox4.Text;
            //数据验证
            //点击录入按钮时,对用户编号进行验证
            if (this.textBox1.Text == "")
            {
                MessageBox.Show("用户编号不能为空,请输入!");
            }
            else
            {
                if (bc.countById(this.textBox1.Text) > 0)  //用户编号已经存在
                {
                    MessageBox.Show("用户编号已经存在,不能重复录入!");
                }
                //符合条件,可以录入
                else
                {
                    int flagReturn = bc.addClientinfo(c);   //返回值大于0,成功;等于0,保存失败
                    if (flagReturn > 0)
                    {
                        MessageBox.Show("录入成功!");
                        this.Close();
                    }
                    else if (flagReturn == 0)
                    {
                        MessageBox.Show("录入失败,请重试");
                    }
                }
            }
        }
예제 #8
0
 //修改用户信息,是否成功
 public int upClientinfo(clientinfo c)
 {
     return(dc.updateClientinfo(c));   //返回值大于0,成功;等于0,保存失败
 }
예제 #9
0
 //删除用户信息,是否成功
 public int delClientinfo(clientinfo c)
 {
     return(dc.deleteClientinfo(c));  //返回值大于0,成功;等于0,保存失败;等于-1,不能删除
 }
예제 #10
0
 //添加用户信息,是否成功
 public int addClientinfo(clientinfo c)
 {
     return(dc.insertClientinfo(c));  //返回值大于0,成功;等于0,保存失败
 }