Пример #1
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            if (!dxValidationProvider1.Validate())
                return;
            var odrs = gcOrder.GetDataSource<t_order>();
            if (odrs == null || odrs.Count < 1) {
                MsgBox.ShowMessage("提示", "没有添加商品不能保存!");
                return;
            }
            if (EditMode == Ultra.Web.Core.Enums.EnViewEditMode.New) {
                var trdnew = new t_trade() {
                    Guid = GuidKey,
                    ReceiverName = memgcEdt.GetSelectedValue().ReceiverName,
                    ReceiverMobile = memgcEdt.GetSelectedValue().ReceiverMobile,
                    ReceiverAddress = memgcEdt.GetSelectedValue().ReceiverAddress,
                    MemberGuid = memgcEdt.GetSelectedValue().Guid,
                    DeliveryDate = dateDeliveryDate.DateTime,
                    CreateDate = TimeSync.Default.CurrentSyncTime,
                    Creator = this.CurUser,
                };

                using (var db = new Database()) {
                    try {
                        db.BeginTransaction();
                        db.Save(trdnew);
                        odrs.ForEach(k => db.Save(k));
                        db.CompleteTransaction();
                    } catch (Exception) {
                        db.AbortTransaction();
                        throw;
                    }
                }
            } else if (EditMode == Ultra.Web.Core.Enums.EnViewEditMode.Edit) {
                using (var db = new Database()) {
                    var trd = db.FirstOrDefault<t_trade>(" where guid=@0", GuidKey);
                    trd.ReceiverName = memgcEdt.GetSelectedValue().ReceiverName;
                    trd.ReceiverMobile = txtMobile.Text;
                    trd.ReceiverAddress = txtReceiverAddress.Text;
                    trd.MemberGuid = memgcEdt.GetSelectedValue().Guid;
                    trd.DeliveryDate = TimeSync.Default.CurrentSyncTime;
                    trd.DeliveryDate = dateDeliveryDate.DateTime;
                    try {
                        db.BeginTransaction();
                        db.Save(trd);
                        db.Execute("delete t_order where tradeguid=@0", trd.Guid);
                        odrs.ForEach(k => {
                            k.Id = 0;
                            db.Save(k);
                        });
                        db.CompleteTransaction();
                    } catch (Exception) {
                        db.AbortTransaction();
                        throw;
                    }
                }
            }
            DialogResult = System.Windows.Forms.DialogResult.OK;
            Close();
        }
Пример #2
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            if (!dxValidationProvider1.Validate())
                return;

            using (var db = new Database()) {
                if (EditMode == Web.Core.Enums.EnViewEditMode.Edit) {
                    var kt = db.FirstOrDefault<t_location>("where locname=@0 and guid <> @1", txtName.Text,GuidKey);
                    if (null != kt) {
                        MsgBox.ShowMessage("提示", "库位名称已存在!");
                        txtName.Select();
                        return;
                    }

                    var et = db.FirstOrDefault<t_location>(" where guid=@0", this.GuidKey);
                    et.WareName = wareGridEdit1.GetSelectedValue().WareName;
                    et.WareCode = wareGridEdit1.GetSelectedValue().WareCode;
                    et.AreaName = areaGridEdit1.GetSelectedValue().AreaName;
                    et.AreaCode = areaGridEdit1.GetSelectedValue().AreaCode;
                    et.LocName = txtName.Text;
                    et.LocCode = txtCode.Text;
                    et.IsUsing = chk.Checked;
                    db.Save(et);
                } else {
                    var kt = db.FirstOrDefault<t_location>("where locname=@0", txtName.Text);
                    if (null != kt) {
                        MsgBox.ShowMessage("提示", "库位名称已存在!");
                        txtName.Select();
                        return;
                    }
                    var et = new t_location {
                        Guid= Guid.NewGuid(),
                        WareName = wareGridEdit1.GetSelectedValue().WareName,
                        WareCode = wareGridEdit1.GetSelectedValue().WareCode,
                        AreaName = areaGridEdit1.GetSelectedValue().AreaName,
                        AreaCode = areaGridEdit1.GetSelectedValue().AreaCode,
                        LocCode = txtCode.Text,
                        LocName = txtName.Text,
                        IsUsing = chk.Checked,
                        Creator=this.CurUser,
                        CreateDate=TimeSync.Default.CurrentSyncTime
                    };
                    db.Save(et);
                }
            }

            DialogResult = System.Windows.Forms.DialogResult.OK;
            Close();
        }
Пример #3
0
        //public static Payment recordPayment(Rider rider, double amount, string branch, string username, string account)
        //{
        //    Payment payment = new Payment();

        //    payment.rider = rider.name;
        //    payment.amount = amount;
        //    payment.paid_date = DateTime.Now;
        //    payment.bank_branch = branch;
        //    payment.bank_username = username;
        //    payment.bank_account = account;

        //    Database db = new PetaPoco.Database(ModelConfig.connectionStringName("bikes"));
        //    db.Insert(payment);

        //    return payment;
        //}

        //public static void deletePayment(int id)
        //{
        //    Database db = new PetaPoco.Database("bikes-clunie");
        //    db.Execute("DELETE FROM payment WHERE id = @0", id);
        //}

        internal void save()
        {
            using (Database db = new PetaPoco.Database(ModelConfig.connectionStringName("bikes")))
            {
                db.Save(this);
            }
        }
Пример #4
0
 void IClass.BatchBuildClass(CheckIn.Model.Class classInfo, DateTime startTime, CycleEnum cycle, int time)
 {
     for (int i = 1; i < time; i++)
     {
         Entity.ClassEntity entity = new Entity.ClassEntity();
         entity.ClassLevel  = classInfo.Level;
         entity.ClassTime   = classInfo.ClassTime;
         entity.Description = classInfo.Description;
         entity.StartTime   = getTime(startTime, cycle, i);
         entity.EndTime     = entity.StartTime.AddMinutes(Common.GlobalVariable.ClassTimeMinute);
         entity.InputTime   = DateTime.Now;
         entity.InputUser   = classInfo.InputUser;
         entity.Name        = classInfo.Name;
         entity.Teacher     = classInfo.Teacher;
         entity.Type        = classInfo.Type;
         _db.Save(entity);
     }
 }
Пример #5
0
 public void save()
 {
     using (Database db = new PetaPoco.Database(ModelConfig.connectionStringName("bikes")))
     {
         if (id == Bike.DefaultId)
         {
             //cannot change name for the default bike
             name = DefaultName;
         }
         db.Save(this);
     }
 }
Пример #6
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            using (var db = new Database()) {
                if (EditMode == Web.Core.Enums.EnViewEditMode.Edit) {
                    var kt = db.FirstOrDefault<t_ware>("where warename=@0 and guid <> @1", txtName.Text,GuidKey);
                    if (null != kt) {
                        MsgBox.ShowMessage("提示", "仓库名称已存在!");
                        txtName.Select();
                        return;
                    }

                    var et = db.FirstOrDefault<t_ware>(" where guid=@0", this.GuidKey);
                    et.WareName = txtName.Text;
                    et.WareCode = txtCode.Text;
                    et.IsUsing = chk.Checked;
                    db.Save(et);
                } else {
                    var kt = db.FirstOrDefault<t_ware>("where warename=@0", txtName.Text);
                    if (null != kt) {
                        MsgBox.ShowMessage("提示", "仓库名称已存在!");
                        txtName.Select();
                        return;
                    }
                    var et = new t_ware {
                        Guid= Guid.NewGuid(),
                        WareCode = txtCode.Text,
                        WareName = txtName.Text,
                        IsUsing = chk.Checked,
                        Creator=this.CurUser,
                        CreateDate=TimeSync.Default.CurrentSyncTime
                    };
                    db.Save(et);
                }
            }

            DialogResult = System.Windows.Forms.DialogResult.OK;
            Close();
        }
Пример #7
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            if (!dxValidationProvider1.Validate())
                return;

            if (MsgBox.ShowYesNoMessage(null, "确定要保存修改吗?") == System.Windows.Forms.DialogResult.No)
                return;
            if (txtpwd.Text != txtrepwd.Text) {
                MsgBox.ShowMessage("", "两次输入的密码不一致!");
                txtpwd.Select();
                return;
            }
            var pwd = string.IsNullOrEmpty(txtpwd.Text) ? "888" : txtpwd.Text;
            var pwde = Util.EncryptPwd(pwd);
            if (EditMode == Ultra.Web.Core.Enums.EnViewEditMode.New) {
                using (var db = new Database()) {
                    //检查用户名唯一性
                    var kt = db.FirstOrDefault<t_user>("select * from t_user where UserName=@0", txtusr.Text);
                    if (null != kt) {
                        MsgBox.ShowMessage("用户已存在", "用户已存在!");
                        txtusr.Select();
                        return;
                    }
                    db.Save(new t_user() {
                        Guid = Guid.NewGuid(),
                        UserName = txtusr.Text,
                        Pwd = pwde,
                        CreateDate = TimeSync.Default.CurrentSyncTime,
                        Creator=this.CurUser,
                        IsUsing=chk.Checked,
                        Remark=string.Empty
                    });
                }
            } else if (EditMode == Ultra.Web.Core.Enums.EnViewEditMode.Edit) {
                using (var db = new Database()) {
                    var et = db.FirstOrDefault<t_user>("where Guid=@0", GuidKey);
                    if (null != et) {
                        et.Guid = Guid.NewGuid();
                        et.UserName = txtusr.Text;
                        et.Pwd = pwde;
                        et.CreateDate = TimeSync.Default.CurrentSyncTime;
                        et.Creator=this.CurUser;
                        et.IsUsing=chk.Checked;
                        et.Remark = string.Empty;
                    }
                }
            }
            DialogResult = System.Windows.Forms.DialogResult.OK;
            Close();
        }
Пример #8
0
        public static Response QueryHelper <T>(string Query = "", string httpVerb = "GET", dynamic payload = null, bool getOneElement = false) where T : class
        {
            try
            {
                using (var db = new PetaPoco.Database("SWATDB"))
                {
                    if (httpVerb == "GET")
                    {
                        if (!getOneElement)
                        {
                            var elements = db.Query <T>(Query).ToList();
                            return(ResponseHelper(ResponseContent: elements, Verb: httpVerb));
                        }
                        else
                        {
                            var elements = db.FirstOrDefault <T>(Query);
                            return(ResponseHelper(ResponseContent: elements, Verb: httpVerb));
                        }
                    }

                    if (httpVerb == "DELETE")
                    {
                        var elements = db.Execute(Query);
                        return(ResponseHelper(ResponseCode: HttpStatusCode.OK, Verb: httpVerb));
                    }

                    if (httpVerb == "POST" && payload != null)
                    {
                        var element = db.Insert(payload);
                        return(ResponseHelper(ResponseContent: element, Verb: httpVerb));
                    }

                    if (httpVerb == "PUT" && payload != null)
                    {
                        db.Save(payload);
                        return(ResponseHelper(Verb: httpVerb));
                    }

                    return(null);
                }
            }
            catch (Exception ex)
            {
                ConsoleMessage(httpVerb, string.Format("Error in {0} Query", typeof(T).GetType()), ex.Message);
                return(HttpStatusCode.InternalServerError);
            }
        }
Пример #9
0
 private void btnOK_Click(object sender, EventArgs e)
 {
     if (!dxValidationProvider1.Validate())
         return;
     if (EditMode == Ultra.Web.Core.Enums.EnViewEditMode.New) {
         using (var db = new Database()) {
             var kt = db.FirstOrDefault<t_item>("select * from t_item where itemno=@0", txtItemNo.Text);
             if (null != kt) {
                 MsgBox.ShowMessage("编码已存在", "编码已存在!");
                 txtItemNo.Select();
                 return;
             }
             db.Save(new t_item() {
                 Guid = Guid.NewGuid(),
                 ItemName  = txtItemName.Text,
                 ItemNo = txtItemNo.Text,
                 Price=spnPrice.Value,
                 CostPrice=spnCostPrice.Value,
                 CreateDate = TimeSync.Default.CurrentSyncTime,
                 Creator=this.CurUser,
                 IsUsing=chk.Checked,
                 Remark=string.Empty
             });
         }
     } else if (EditMode == Ultra.Web.Core.Enums.EnViewEditMode.Edit) {
         using (var db = new Database()) {
             var et = db.FirstOrDefault<t_item>("where Guid=@0", GuidKey);
             if (null != et) {
                 et.ItemName = txtItemName.Text;
                 et.ItemNo = txtItemNo.Text;
                 et.Price=spnPrice.Value;
                 et.CostPrice = spnCostPrice.Value;
                 et.IsUsing=chk.Checked;
                 et.Remark = string.Empty;
             }
             db.Save(et);
         }
     }
     DialogResult = System.Windows.Forms.DialogResult.OK;
     Close();
 }
Пример #10
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            if (MsgBox.ShowYesNoMessage(null, "确定要保存吗?") == System.Windows.Forms.DialogResult.No)
                return;
            var usr = GetCurUser<t_user>();
            for (int i = 0; i < memedt.Lines.Length; i++)
            {
                memedt.Lines[i] = memedt.Lines[i].Replace("-", string.Empty);
            }
            var exp = memedt.Lines.ToList().Where(k=>!string.IsNullOrEmpty(k.Trim().Replace("\r",string.Empty).Replace("\n",string.Empty))).Except(LstMac.Select(k => k.Mac).ToList()).ToList();
            var ndel = LstMac.Select(k => k.Mac).ToList().Except(memedt.Lines.ToList().Where(k => !string.IsNullOrEmpty(k.Trim().Replace("\r", string.Empty).Replace("\n", string.Empty))).ToList()).ToList();
            if (null != exp && exp.Count > 0)
            {
                using (var db = new Database())
                {
                    exp.ForEach(k =>
                    {

                        db.Save(new t_mac
                        {
                            Guid = Guid.NewGuid(),
                            IsUsing = true,
                            Mac = k,
                            Creator = usr.UserName,
                            CreateDate=TimeSync.Default.CurrentSyncTime
                        });
                    });
                }
            }
            if (null != ndel && ndel.Count > 0)
            {
                var ins = ndel.Select(k=>"'"+k+"'").Aggregate((s1,s2)=>  s1+","+s2).ToString();
                SqlHelper.ExecuteNonQuery(ConnString,CommandType.Text,
                    string.Format("delete from t_mac where mac in ({0})", ins));
            }
            //MsgBox.ShowMessage(null, "保存成功!");
            DialogResult = System.Windows.Forms.DialogResult.OK;
            Close();
        }
Пример #11
0
 private void btnOK_Click(object sender, EventArgs e)
 {
     if (!dxValidationProvider1.Validate()) return;
     if (EditMode == Ultra.Web.Core.Enums.EnViewEditMode.New)
     {
         using (var db = new Database())
         {
             var et = db.FirstOrDefault<t_role>("where Name=@0", txtname.Text.Trim());
             if (null != et)
             {
                 MsgBox.ShowMessage(null, "名称已存在,不可重复添加!");
                 return;
             }
             db.Save(new t_role
             {
                 Guid = Guid.NewGuid(),
                 IsUsing = chk.Checked,
                 Name = txtname.Text.Trim(),
                 Creator = this.CurUser,
                 Desc=txtdesc.Text.Trim(),
                 CreateDate=TimeSync.Default.CurrentSyncTime,
                 Remark=string.Empty
             });
         }
     } else if (EditMode == Ultra.Web.Core.Enums.EnViewEditMode.Edit)
     {
         using (var db = new Database())
         {
             var et = db.FirstOrDefault<t_role>(" where guid=@0", GuidKey);
             if (et != null)
             {
                 db.Update<t_role>(" set isusing=@0,[desc]=@1 where guid=@2", chk.Checked, txtdesc.Text.Trim(), et.Guid);
             }
         }
     }
     DialogResult = System.Windows.Forms.DialogResult.OK;
     Close();
 }
Пример #12
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            if (!dxValidationProvider1.Validate())
                return;
            if (EditMode == Ultra.Web.Core.Enums.EnViewEditMode.New) {
                using (var db = new Database()) {
                    db.Save(new t_member() {
                        Guid = Guid.NewGuid(),
                        ReceiverNo  = txtReceiverNo.Text,
                        ReceiverName = txtReceiverName.Text,
                        ReceiverMobile=txtReceiverMobile.Text,
                        ReceiverAddress=txtReceiverAddress.Text,
                        CreateDate = TimeSync.Default.CurrentSyncTime,
                        Creator=this.CurUser,
                        IsUsing=chk.Checked,
                        Remark=txtRemark.Text
                    });
                }
            } else if (EditMode == Ultra.Web.Core.Enums.EnViewEditMode.Edit) {
                using (var db = new Database()) {
                    var et = db.FirstOrDefault<t_member>("where Guid=@0", GuidKey);
                    if (null != et) {
                        et.ReceiverNo  = txtReceiverNo.Text;
                        et.ReceiverName = txtReceiverName.Text;
                        et.ReceiverMobile=txtReceiverMobile.Text;
                        et.ReceiverAddress=txtReceiverAddress.Text;
                        et.IsUsing=chk.Checked;
                        et.Remark = txtRemark.Text;

                    }
                    db.Save(et);
                }
            }
            DialogResult = System.Windows.Forms.DialogResult.OK;
            Close();
        }
Пример #13
0
        string IStudent.ImportStudent(string file)
        {
            var    ds = GetExcelData(file);
            int    i = 0, j = 0;
            string msg = "";

            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                try
                {
                    var saveStudent = new entity.StudentEntity();
                    saveStudent.Name            = dr[1].ToString();
                    saveStudent.FatherTelephone = dr[2].ToString();
                    saveStudent.MotherTelephone = dr[3].ToString();
                    _db.Save(saveStudent);
                    i++;
                }
                catch (Exception e)
                {
                    j++;
                }
            }
            return(string.Format("成功导入数据{0}条,失败{1}条", i, j));
        }
Пример #14
0
        protected void SaveNewUpd(bool flgChkAuto)
        {
            bool flgNew   = false;
            bool flgValid = false;

            try
            {
                //Validate first...
                flgValid = validateFields();
                //
                if (!flgValid)
                {
                    return;
                }

                // Create a PetaPoco database object
                var db = new PetaPoco.Database("Shell_AutoArchDBConnectionString");

                // Get a record
                var a = db.SingleOrDefault <planning>("SELECT * FROM shell_Planning WHERE UniqueId=@0", txt_uniqueid.Text);

                //Test if record exists...
                if (null == a)
                {
                    a      = new planning();
                    flgNew = true;
                }
                //if update, check if status is not equal to CVR... or Closed...
                else if (flgChkAuto)
                {
                    if (txt_status.Text.IndexOf("Archival Order Closed") == -1)
                    {
                        if ((a.Status.IndexOf("Rejected") >= 0) || (a.Status.IndexOf("CVR Created") >= 0)) //Rejected
                        {
                            ClrFields(false);
                            return;
                        }
                    }
                }

                // Change it
                //
                if (txt_actaoenddate.Text != a.ActAOEndDate.ToString("yyyy-MM-dd HH:mm:ss.ttt"))
                {
                    a.ActAOEndDate = DateTime.Parse(txt_actaoenddate.Text);
                }
                //
                if (txt_actaoreceivedate.Text != a.ActAOReceiveDate.ToString("yyyy-MM-dd HH:mm:ss.ttt"))
                {
                    a.ActAOReceiveDate = DateTime.Parse(txt_actaoreceivedate.Text);
                }
                //
                if (txt_actaostartdate.Text != a.ActAOStartDate.ToString("yyyy-MM-dd HH:mm:ss.ttt"))
                {
                    a.ActAOStartDate = DateTime.Parse(txt_actaostartdate.Text);
                }
                //
                if (txt_colsitenum.Text != "")
                {
                    if (Convert.ToInt16(txt_colsitenum.Text) != a.ColSiteNum)
                    {
                        a.ColSiteNum = Convert.ToInt16(txt_colsitenum.Text);
                    }
                }
                //
                if (txt_comment.Text != a.Comment)
                {
                    a.Comment = txt_comment.Text;
                }
                //
                if (chk_dataexpctrchk.Checked)
                {
                    a.DataExpCtrChk = 1;
                }
                else
                {
                    a.DataExpCtrChk = 0;
                }
                //
                if (txt_duname.Text != a.DUName)
                {
                    a.DUName = txt_duname.Text;
                }
                //
                //
                if ((txt_actaostartdate.Text != "") && (txt_actaoenddate.Text != ""))
                {
                    DateTime dtf = DateTime.Parse(txt_actaostartdate.Text);
                    DateTime dtt = DateTime.Parse(txt_actaoenddate.Text);
                    a.DurationWorkDays = GetWorkingDays(dtf, dtt);
                }
                else if (Convert.ToInt16(txt_durationworkdays.Text) != a.DurationWorkDays)
                {
                    a.DurationWorkDays = Convert.ToInt16(txt_durationworkdays.Text);
                }
                //
                //
                if (txt_operatorname.Text != a.OperatorName)
                {
                    a.OperatorName = txt_operatorname.Text;
                }
                //
                if (txt_planaoenddate.Text != a.PlanAOEndDate.ToString("yyyy-MM-dd HH:mm:ss.ttt"))
                {
                    a.PlanAOEndDate = DateTime.Parse(txt_planaoenddate.Text);
                }
                //
                if (txt_planaoreceivedate.Text != a.PlanAOReceiveDate.ToString("yyyy-MM-dd HH:mm:ss.ttt"))
                {
                    a.PlanAOReceiveDate = DateTime.Parse(txt_planaoreceivedate.Text);
                }
                //
                if (txt_planaostartdate.Text != a.PlanAOStartDate.ToString("yyyy-MM-dd HH:mm:ss.ttt"))
                {
                    a.PlanAOStartDate = DateTime.Parse(txt_planaostartdate.Text);
                }
                //
                if (txt_status.Text != a.Status)
                {
                    a.Status = txt_status.Text;
                }
                //
                if (txt_instanceid.Text != a.InstanceId)
                {
                    a.InstanceId = txt_instanceid.Text;
                }
                //
                if ((float)Convert.ToDouble(txt_volumegb.Text) != a.VolumeGB)
                {
                    a.VolumeGB = (float)Convert.ToDouble(txt_volumegb.Text);
                }
                //
                if (chk_waiverchk.Checked)
                {
                    a.WaiverChk = 1;
                }
                else
                {
                    a.WaiverChk = 0;
                }
                //

                string msg = "Archiving Order updated! - ";
                if (flgNew)
                {
                    a.UniqueId = txt_uniqueid.Text;
                    msg        = "New Archiving Order inserted! - ";
                    db.Save(a);
                }
                else
                {
                    db.Update(a);
                }

                if (flgChkAuto)
                {
                    divMessage.InnerHtml += "<span id='msg' style='color:#FF3300;font-size:Smaller;font-weight:bold;'>" + msg + txt_uniqueid.Text + "  </span><br>";
                }
                else
                {
                    divMessage.InnerHtml = "<span id='msg' style='color:#FF3300;font-size:Smaller;font-weight:bold;'>" + msg + txt_uniqueid.Text + "  </span>";
                }
            }
            catch (Exception eg)
            {
                if (flgChkAuto)
                {
                    divMessage.InnerHtml += "<span id='msg' style='color:#FF3300;font-size:Smaller;font-weight:bold;'>" + "Error Message: " + eg.Message + "  </span>";
                }
                else
                {
                    divMessage.InnerHtml = "<span id='msg' style='color:#FF3300;font-size:Smaller;font-weight:bold;'>" + "Error Message: " + eg.Message + "  </span>";
                }
            }
        }
Пример #15
0
        public static string CrearCiudad(Ciudad ciudad)
        {
            try {
                using (var db = new Database("riesgos")) {
                    var cuenta = db.SingleOrDefault<int>("select count(id) from ciudad where nombre = @0", ciudad.Nombre);
                    if (cuenta > 0) return "Ya existe una ciudad con el mismo nombre";
                    db.Save("ciudad", "id", ciudad);
                    return "";
                }

            } catch (Exception ex) {
                return "Error de ejecución: " + ex.Message;
            }
        }
Пример #16
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            var items = gcItem.GetDataSource<t_instockitem>();
            if (items == null || items.Count < 1) {
                MsgBox.ShowMessage("", "没有商品信息,不能保存!");
                return;
            }
            if (items.Any(K => string.IsNullOrEmpty(K.ItemNo))) {
                MsgBox.ShowMessage("", "商品信息不完整!");
                return;
            }

            if (EditMode == Web.Core.Enums.EnViewEditMode.Edit) {
                using (var db = new Database()) {
                    try {
                        db.BeginTransaction();
                        db.Execute("delete t_instockitem where instockno=@0", InStockNo);
                        InStock.Remark = txtRemark.Text;
                        InStock.Num = items.Sum(k => k.Num);
                        InStock.OuterNo = txtOuterNo.Text;
                        db.Save(InStock);
                        items.ForEach(k => { k.Id = 0; db.Save(k); });

                        db.CompleteTransaction();
                    } catch (Exception) {
                        db.AbortTransaction();
                        throw;
                    }
                }
            } else {

                InStock = new t_instock();
                InStock.Remark = txtRemark.Text;
                InStock.Guid = GuidKey;
                InStock.InStockNo = InStockNo;
                InStock.OuterNo = txtOuterNo.Text;
                InStock.Creator = this.CurUser;
                InStock.AuditDate = InStock.CreateDate = TimeSync.Default.CurrentSyncTime;
                InStock.Num = items.Sum(k => k.Num);

                using (var db = new Database()) {
                    try {
                        db.BeginTransaction();
                        db.Save(InStock);
                        items.ForEach(k => db.Save(k));

                        db.CompleteTransaction();
                    } catch (Exception) {
                        db.AbortTransaction();
                        throw;
                    }
                }

            }

            DialogResult = DialogResult.OK;
            Close();
        }
Пример #17
0
 private void btnSaveToSvr_Click(object sender, EventArgs e)
 {
     if (MsgBox.ShowYesNoMessage("", "确定要保存菜单至服务器?") == System.Windows.Forms.DialogResult.No)
         return;
     using (var db = new Database()) {
         var mnu = db.FirstOrDefault<t_menu>("select * from t_menu");
         if (mnu == null)
         {
             mnu = new t_menu
             {
                 Guid = Guid.NewGuid(),
                 Version = "1.0",
                 MenuXml = BuildMenuXml(),
                 CreateDate = TimeSync.Default.CurrentSyncTime
             };
         }
         else {
             mnu.MenuXml = BuildMenuXml();
         }
         db.Save(mnu);
     }
     MsgBox.ShowMessage("", "保存成功!");
 }
Пример #18
0
        private void btnOK_Click(object sender, EventArgs ea)
        {
            var k = roleGridEdit1.GetSelectedValue();
            if (null == k) return;
            List<MenuCtlData> lst = new List<MenuCtlData>(100);
            foreach (TreeListNode td in treeCtl1.Nodes)
            {
                var mnugrp = td.GetValue(0).ToString();
                foreach (TreeListNode tds in td.Nodes)
                {
                    var mnuname = tds.GetValue(0).ToString();
                    foreach (TreeListNode tmd in tds.Nodes)
                    {
                        var mcd = tmd.Tag as MenuCtlData;
                        if (null != mcd)
                        {
                            mcd.IsEnabled = tmd.Checked;
                            mcd.MenuGrpName = mnugrp;
                            mcd.MenuName = mnuname;
                            lst.Add(mcd);
                        }
                        foreach (TreeListNode tkd in tmd.Nodes)
                        {
                            var md = tkd.Tag as MenuCtlData;
                            if (null == md) continue;
                            md.IsEnabled = tkd.Checked;
                            md.MenuGrpName = mnugrp; md.MenuName = mnuname;
                            lst.Add(md);
                        }
                    }
                }
            }
            var usr = GetCurUser<t_user>();
            using (var db = new Database())
            {

                var et = db.FirstOrDefault<t_roleset>("select * from t_roleset where RoleId=@0", k.Id);

                var roleset = et;
                if (et != null)
                {
                    roleset.RoleSetTree = Ultra.Web.Core.Common.ObjectHelper.SerializeJson(lst);
                }
                else
                {
                    roleset = new t_roleset
                    {
                        RoleSetTree = Ultra.Web.Core.Common.ObjectHelper.SerializeJson(lst),
                        RoleId = k.Id,
                        IsUsing = true,
                        RoleName = k.Name,
                        Guid = Guid.NewGuid(),
                        Creator =this.CurUser,
                        CreateDate = TimeSync.Default.CurrentSyncTime
                    };
                }
                db.Save(roleset);
            }
            MsgBox.ShowMessage(null, "保存成功!");
        }
Пример #19
0
 private void btnOK_Click(object sender, EventArgs e)
 {
     if (!dxValidationProvider1.Validate())
         return;
     var odrs = gcOrder.GetDataSource<t_retorder>();
     if (odrs == null || odrs.Count < 1) {
         MsgBox.ShowMessage("提示", "没有退货商品不能保存退货单!");
         return;
     }
     if (odrs.Any(k=>string.IsNullOrEmpty(k.LocName))) {
         MsgBox.ShowMessage("提示", "所有商品都必须选择库位!");
         return;
     }
     if (EditMode == Ultra.Web.Core.Enums.EnViewEditMode.New) {
         var rettrd = this.Trade;
         rettrd.Guid = Guid.NewGuid();
         rettrd.Id = 0;
         rettrd.IsAudit = false;
         using (var db = new Database()) {
             try {
                 db.BeginTransaction();
                 db.Save(rettrd);
                 odrs.ForEach(k => {
                     k.Guid = Guid.NewGuid();
                     k.Id = 0;
                     k.TradeGuid = rettrd.Guid;
                     db.Save(k);
                 });
                 db.CompleteTransaction();
             } catch (Exception) {
                 db.AbortTransaction();
                 throw;
             }
         }
     } else if (EditMode == Ultra.Web.Core.Enums.EnViewEditMode.Edit) {
         using (var db = new Database()) {
             var trd = db.FirstOrDefault<t_rettrade>(" where guid=@0", GuidKey);
             trd.ReceiverName = Trade.ReceiverName;
             trd.ReceiverMobile = txtMobile.Text;
             trd.ReceiverAddress = txtReceiverAddress.Text;
             trd.MemberGuid = Trade.Guid;
             trd.DeliveryDate = TimeSync.Default.CurrentSyncTime;
             trd.DeliveryDate = dateDeliveryDate.DateTime;
             try {
                 db.BeginTransaction();
                 db.Save(trd);
                 db.Execute("delete t_retorder where tradeguid=@0", trd.Guid);
                 odrs.ForEach(k => {
                     k.Id = 0;
                     db.Save(k);
                 });
                 db.CompleteTransaction();
             } catch (Exception) {
                 db.AbortTransaction();
                 throw;
             }
         }
     }
     DialogResult = System.Windows.Forms.DialogResult.OK;
     Close();
 }
Пример #20
0
 public void setAsPaid(int paymentId)
 {
     payment_id = paymentId;
     paid = true;
     using (Database db = new PetaPoco.Database(ModelConfig.connectionStringName("bikes")))
     {
         db.Save(this);
     }
 }