Exemple #1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                txtID.Text = txtID.Text.ToUpper();
                if (ValidData())
                {
                    switch (vAction)
                    {
                    case action.Insert:
                        var obj = new LUser();
                        obj.UserName = Utility.sDbnull(txtName.Text);
                        obj.UserCode = Utility.sDbnull(cboUserName.Text);
                        obj.IsNew    = true;
                        obj.Save();

                        drList = dtList.NewRow();
                        drList[LUser.Columns.UserId] = LUser.CreateQuery().GetMax(LUser.Columns.UserId);
                        ApplyData2Datarow();
                        dtList.Rows.InsertAt(drList, 0);
                        dtList.AcceptChanges();

                        txtID.Text = Utility.sDbnull(drList[LUser.Columns.UserId]);
                        vAction    = action.Update;
                        break;

                    case action.Update:
                        new Update(LUser.Schema.Name).Set(LUser.Columns.UserName).EqualTo(txtName.Text).
                        Set(LUser.Columns.UserCode).EqualTo(Utility.sDbnull(cboUserName.Text)).
                        Where(LUser.Columns.UserId).IsEqualTo(Utility.Int32Dbnull(txtID.Text)).
                        Execute();
                        ApplyData2Datarow();
                        drList.AcceptChanges();
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                Utility.ShowMsg(ex.Message);
            }
        }
Exemple #2
0
        public static string InsertDoctor(LUser pitems)
        {
            int   i        = 0;
            Query _QueryRS = LUser.CreateQuery();

            try
            {
                if (!LUser.FetchByParameter(LUser.Columns.UserId, Comparison.Equals, pitems.UserId).Read())
                {
                    pitems.IsNew = true;
                    pitems.Save(i);
                    return(_QueryRS.GetMax(LUser.Columns.UserId).ToString());
                }
                else
                {
                    return("-1");
                    //throw new Exception(string.Format("Name:{0} Đã tồn tại", pitems.IPAddress));
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }