コード例 #1
0
ファイル: LocEditView.cs プロジェクト: ZixiangBoy/YongERP
        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();
        }
コード例 #2
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, "保存成功!");
        }
コード例 #3
0
ファイル: route.cs プロジェクト: catflinger/bikes
 public static Route getRoute(int id)
 {
     using (Database db = new PetaPoco.Database(ModelConfig.connectionStringName("bikes")))
     {
         return db.FirstOrDefault<Route>("WHERE id = @0", id);
     }
 }
コード例 #4
0
ファイル: rider.cs プロジェクト: catflinger/bikes
 public static Rider getRider(int id)
 {
     using (Database db = new PetaPoco.Database(ModelConfig.connectionStringName("bikes")))
     {
         Rider rider = db.FirstOrDefault<Rider>("WHERE id = @0", id);
         return rider;
     }
 }
コード例 #5
0
ファイル: rider.cs プロジェクト: catflinger/bikes
 public static Rider findRiderByName(string name)
 {
     using (Database db = new PetaPoco.Database(ModelConfig.connectionStringName("bikes")))
     {
         Rider rider = db.FirstOrDefault<Rider>("WHERE name = @0", name);
         return rider;
     }
 }
コード例 #6
0
ファイル: rider.cs プロジェクト: catflinger/bikes
 public static string getPwd(int id)
 {
     using (Database db = new PetaPoco.Database(ModelConfig.connectionStringName("bikes")))
     {
         PwdPoco poco = db.FirstOrDefault<PwdPoco>("WHERE id = @0", id);
         return poco.pwd;
     }
 }
コード例 #7
0
ファイル: WareEditView.cs プロジェクト: ZixiangBoy/YongERP
 private void WareEditView_Load(object sender, EventArgs e)
 {
     if (EditMode == Web.Core.Enums.EnViewEditMode.Edit) {
         using (var db = new Database()) {
             var ware = db.FirstOrDefault<t_ware>(" where guid=@0",this.GuidKey);
             txtName.Text = ware.WareName;
             txtCode.Text = ware.WareCode;
             chk.Checked = ware.IsUsing;
         }
     }
 }
コード例 #8
0
    public string getProvider(string username, string password)
    {
        using (var db = new PetaPoco.Database("linkSTEM"))
        {
            var SQL = Sql.Builder.Append("SELECT *")
                      .Append("FROM [dbo].[Providers]")
                      .Append("WHERE [provider_Username] = @0 AND [provider_Password] = @1", username, password);

            return(JsonConvert.SerializeObject(db.FirstOrDefault <Provider>(SQL)));
        }
    }
コード例 #9
0
ファイル: WareEditView.cs プロジェクト: ZixiangBoy/YongERP
        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();
        }
コード例 #10
0
ファイル: NewView.cs プロジェクト: MasterGao/DevWinFormFrame
        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();
        }
コード例 #11
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);
            }
        }
コード例 #12
0
ファイル: NewView.cs プロジェクト: MasterGao/DevWinFormFrame
 private void NewView_Load(object sender, EventArgs e)
 {
     if (EditMode == Ultra.Web.Core.Enums.EnViewEditMode.Edit)
     {
         txtname.Properties.ReadOnly = true;
         using (var db = new Database())
         {
             var et = db.FirstOrDefault<t_role>(" where guid=@0", GuidKey);
             if (null != et)
             {
                 txtname.Text = et.Name;
                 txtdesc.Text = et.Desc;
                 chk.Checked = et.IsUsing;
             }
         }
     }
 }
コード例 #13
0
ファイル: NewView.cs プロジェクト: ZixiangBoy/YongERP
 private void NewView_Load(object sender, EventArgs e)
 {
     if (EditMode == Ultra.Web.Core.Enums.EnViewEditMode.Edit) {
         using (var db = new Database()) {
             try {
                 var et = db.FirstOrDefault<t_item>("where Guid=@0", GuidKey);
                 if (null != et) {
                     txtItemName.Text = et.ItemName;
                     txtItemNo.Text = et.ItemNo;
                     spnPrice.Value = et.Price;
                     chk.Checked = et.IsUsing;
                 }
             } catch (Exception ex) {
                 throw ex;
             }
         }
         txtItemName.Properties.ReadOnly = true;
     }
 }
コード例 #14
0
ファイル: NewView.cs プロジェクト: ZixiangBoy/YongERP
 private void NewView_Load(object sender, EventArgs e)
 {
     if (EditMode == Ultra.Web.Core.Enums.EnViewEditMode.Edit) {
         using (var db = new Database()) {
             try {
                 var et = db.FirstOrDefault<t_member>("where Guid=@0", GuidKey);
                 if (null != et) {
                     txtReceiverNo.Text = et.ReceiverNo;
                     txtReceiverName.Text = et.ReceiverName;
                     txtReceiverMobile.Text = et.ReceiverMobile;
                     txtReceiverAddress.Text = et.ReceiverAddress;
                     txtRemark.Text = et.Remark;
                     chk.Checked = et.IsUsing;
                 }
             } catch (Exception ex) {
                 throw ex;
             }
         }
     }
 }
コード例 #15
0
ファイル: NewView.cs プロジェクト: ZixiangBoy/YongERP
 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();
 }
コード例 #16
0
ファイル: NewView.cs プロジェクト: MasterGao/DevWinFormFrame
 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();
 }
コード例 #17
0
ファイル: NewView.cs プロジェクト: ZixiangBoy/YongERP
        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();
        }
コード例 #18
0
        private void PermitView_Load(object sender, EventArgs e)
        {
            this.btnClose.Left = this.Width - this.btnClose.Width - 30;
            this.btnOK.Left = this.btnClose.Left - this.btnOK.Width - 10;
            roleGridEdit1.LoadData();
            treeCtl1.AfterCheckNode += treeCtl1_AfterCheckNode; treeCtl1.Enabled = false;
            t_menu mnu;
            using (var db = new Database())
            {
                mnu = db.FirstOrDefault<t_menu>("select * from t_menu");
                //解析菜单XML
                treeCtl1.ClearNodes();
                ExtractMenu(mnu.MenuXml);
            }
            dlg = new DevExpress.Utils.WaitDialogForm("正在加载权限设置信息 ...",
                "数据加载中");

            var t = new Thread(() =>
            {
                //加载菜单
                this.Invoke(new Action(() =>
                {
                    BuildlRoleTree(); Visible = true;
                }));
                this.Invoke(new Action(() => dlg.Close()));
            });
            t.SetApartmentState(ApartmentState.STA);
            t.IsBackground = true;
            t.Start();
        }
コード例 #19
0
ファイル: LocEditView.cs プロジェクト: ZixiangBoy/YongERP
        private void LocEditView_Load(object sender, EventArgs e)
        {
            wareGridEdit1.LoadData();
            areaGridEdit1.LoadData();

            if (EditMode == Web.Core.Enums.EnViewEditMode.Edit) {
                using (var db = new Database()) {
                    var loc = db.FirstOrDefault<t_location>(" where guid=@0",this.GuidKey);

                    wareGridEdit1.SetSelectedValue(db.FirstOrDefault<t_ware>(" where warename = @0", loc.WareName));
                    areaGridEdit1.SetSelectedValue(db.FirstOrDefault<t_area>(" where areaname = @0", loc.AreaName));
                    txtName.Text = loc.LocName;
                    txtCode.Text = loc.LocCode;
                    chk.Checked = loc.IsUsing;
                }
            }
        }
コード例 #20
0
 private void roleGridEdit1_EditValueChanged(object sender, EventArgs e)
 {
     var m = roleGridEdit1.SelectedValue;
     if (null == m) { treeCtl1.Enabled = false; return; }
     treeCtl1.Enabled = true;
     using (var db = new Database())
     {
         var et = db.FirstOrDefault<t_roleset>("select * from t_roleset where RoleId=@0",m.Id);
         if (null == et)
         {
             //treeCtl1.AfterCheckNode -= treeCtl1_AfterCheckNode;
             ClearNodeCheck();
             //treeCtl1.AfterCheckNode += treeCtl1_AfterCheckNode;
         }
         else
         {
             //treeCtl1.AfterCheckNode -= treeCtl1_AfterCheckNode;
             var roletree = Ultra.Web.Core.Common.ObjectHelper.DeSerialize<List<MenuCtlData>>(et.RoleSetTree);
             SetNodeRole(roletree);
             //List<TreeListNode> lst = null;
             //CollectNode(null, ref lst);
         }
     }
 }
コード例 #21
0
ファイル: Core.cs プロジェクト: JonathanValle/mixerp
        public MixERP.Net.Entities.Core.TaxRateType GetSingle(string id)
        {
            ApiAccessPolicy policy = new ApiAccessPolicy(typeof(MixERP.Net.Entities.Core.TaxRateType), "GET");
            policy.Authorize();

            if (!policy.IsAuthorized)
            {
                throw new HttpResponseException(HttpStatusCode.Forbidden);
            }

            try
            {
                using (Database db = new Database(Factory.GetConnectionString(), "Npgsql"))
                {
                    return db.FirstOrDefault<MixERP.Net.Entities.Core.TaxRateType>("SELECT * FROM core.tax_rate_types WHERE tax_rate_type_code=@0", id);
                }
            }
            catch
            {
                throw new HttpResponseException(HttpStatusCode.InternalServerError);
            }
        }
コード例 #22
0
ファイル: Core.cs プロジェクト: JonathanValle/mixerp
        public MixERP.Net.Entities.Core.ShippingAddress GetSingle(long id)
        {
            ApiAccessPolicy policy = new ApiAccessPolicy(typeof(MixERP.Net.Entities.Core.ShippingAddress), "GET");
            policy.Authorize();

            if (!policy.IsAuthorized)
            {
                throw new HttpResponseException(HttpStatusCode.Forbidden);
            }

            try
            {
                using (Database db = new Database(Factory.GetConnectionString(), "Npgsql"))
                {
                    return db.FirstOrDefault<MixERP.Net.Entities.Core.ShippingAddress>("SELECT * FROM core.shipping_addresses WHERE shipping_address_id=@0", id);
                }
            }
            catch
            {
                throw new HttpResponseException(HttpStatusCode.InternalServerError);
            }
        }
コード例 #23
0
ファイル: Core.cs プロジェクト: JonathanValle/mixerp
        public MixERP.Net.Entities.Core.SalesTaxExemptDetail GetSingle(int id)
        {
            ApiAccessPolicy policy = new ApiAccessPolicy(typeof(MixERP.Net.Entities.Core.SalesTaxExemptDetail), "GET");
            policy.Authorize();

            if (!policy.IsAuthorized)
            {
                throw new HttpResponseException(HttpStatusCode.Forbidden);
            }

            try
            {
                using (Database db = new Database(Factory.GetConnectionString(), "Npgsql"))
                {
                    return db.FirstOrDefault<MixERP.Net.Entities.Core.SalesTaxExemptDetail>("SELECT * FROM core.sales_tax_exempt_details WHERE sales_tax_exempt_detail_id=@0", id);
                }
            }
            catch
            {
                throw new HttpResponseException(HttpStatusCode.InternalServerError);
            }
        }
コード例 #24
0
ファイル: NewView.cs プロジェクト: ZixiangBoy/YongERP
        private void NewView_Load(object sender, EventArgs e)
        {
            memgcEdt.LoadData();
            dateDeliveryDate.DateTime = TimeSync.Default.CurrentSyncTime;

            using (var db = new Database()) {
                rspItem.DataSource = db.Fetch<t_item>(" where isnull(isusing,0)=1 ");

                if (EditMode == Ultra.Web.Core.Enums.EnViewEditMode.New) {
                    GuidKey = Guid.NewGuid();
                } else {
                    var trd = db.FirstOrDefault<t_trade>(" where guid=@0", GuidKey);
                    memgcEdt.SetSelectedValue(db.FirstOrDefault<t_member>(" where guid=@0", trd.MemberGuid));
                    txtMobile.Text = trd.ReceiverMobile;
                    txtReceiverAddress.Text = trd.ReceiverAddress;
                    dateDeliveryDate.DateTime = trd.DeliveryDate ?? TimeSync.Default.CurrentSyncTime;
                    gcOrder.DataSource = db.Fetch<t_order>(" where tradeguid=@0",GuidKey);
                }
            }
        }
コード例 #25
0
ファイル: NewView.cs プロジェクト: flyeven/YongERP
        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 = Trade.ReceiverName,
                    ReceiverMobile = Trade.ReceiverMobile,
                    ReceiverAddress = Trade.ReceiverAddress,
                    MemberGuid = Trade.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 = 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_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();
        }
コード例 #26
0
ファイル: CRM.cs プロジェクト: JonathanValle/mixerp
        public MixERP.Net.Entities.CRM.LeadSource GetSingle(int id)
        {
            ApiAccessPolicy policy = new ApiAccessPolicy(typeof(MixERP.Net.Entities.CRM.LeadSource), "GET");
            policy.Authorize();

            if (!policy.IsAuthorized)
            {
                throw new HttpResponseException(HttpStatusCode.Forbidden);
            }

            try
            {
                using (Database db = new Database(Factory.GetConnectionString(), "Npgsql"))
                {
                    return db.FirstOrDefault<MixERP.Net.Entities.CRM.LeadSource>("SELECT * FROM crm.lead_sources WHERE lead_source_id=@0", id);
                }
            }
            catch
            {
                throw new HttpResponseException(HttpStatusCode.InternalServerError);
            }
        }
コード例 #27
0
ファイル: MenuView.cs プロジェクト: MasterGao/DevWinFormFrame
 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("", "保存成功!");
 }
コード例 #28
0
ファイル: MenuView.cs プロジェクト: MasterGao/DevWinFormFrame
 private void MenuView_Load(object sender, EventArgs e)
 {
     t_menu mnu;
     using (var db = new Database()) {
         mnu = db.FirstOrDefault<t_menu>("select * from t_menu");
         if (null == mnu || string.IsNullOrEmpty(mnu.MenuXml))
         {
             treeCtl1.ClearNodes();
             mnu = new t_menu
             {
                 MenuXml = BuildMenuXml(),
                 Version = "1.0"
             };
         }
     }
     //解析菜单XML
     treeCtl1.ClearNodes();
     ExtractMenu(mnu.MenuXml);
 }
コード例 #29
0
ファイル: IndexDao.cs プロジェクト: RodH257/RetrEave
        /// <summary>
        /// Gets the oldest index of at least a certain minimum age
        /// </summary>
        /// <param name="minumumAge"></param>
        /// <returns></returns>
        public RetreaveIndex GetMostOutdatedIndex(DateTime minumumAge)
        {
            var result = _database.FirstOrDefault <RetreaveIndex>("WHERE LastProcessed < @0 AND Active = 1 ORDER BY LastProcessed ASC ", minumumAge);

            return(FillResult(result));
        }
コード例 #30
0
ファイル: Tag.cs プロジェクト: KerwinMa/OurUmbraco
 public static Tag GetByName(string name)
 {
     var db = new Database("umbracoDbDSN");
     var tag = db.FirstOrDefault<Tag>("WHERE tag = @0", name);
     return tag;
 }
コード例 #31
0
ファイル: Core.cs プロジェクト: JonathanValle/mixerp
        public MixERP.Net.Entities.Core.AttachmentLookup GetSingle(int id)
        {
            ApiAccessPolicy policy = new ApiAccessPolicy(typeof(MixERP.Net.Entities.Core.AttachmentLookup), "GET");
            policy.Authorize();

            if (!policy.IsAuthorized)
            {
                throw new HttpResponseException(HttpStatusCode.Forbidden);
            }

            try
            {
                using (Database db = new Database(Factory.GetConnectionString(), "Npgsql"))
                {
                    return db.FirstOrDefault<MixERP.Net.Entities.Core.AttachmentLookup>("SELECT * FROM core.attachment_lookup WHERE attachment_lookup_id=@0", id);
                }
            }
            catch
            {
                throw new HttpResponseException(HttpStatusCode.InternalServerError);
            }
        }
コード例 #32
0
ファイル: NewView.cs プロジェクト: ZixiangBoy/YongERP
 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();
 }
コード例 #33
0
ファイル: MainView.cs プロジェクト: MasterGao/DevWinFormFrame
        private void LoadMenu()
        {
            this.navMenu.Groups.Clear();
            t_menu mnu;
            using (var db = new Database()) {
                mnu = db.FirstOrDefault<t_menu>("select * from t_menu");
                if (null == mnu || string.IsNullOrEmpty(mnu.MenuXml))
                    return;
            }
            XDocument xdoc = XDocument.Parse(mnu.MenuXml);
            foreach (XElement item in xdoc.Element("Menus").Elements()) {
                var md = new MenuData {
                    IsUsing = true,
                    MenuGrpName = item.Attribute("Name").Value,
                    MenuItem = null
                };
                //var td = treeCtl1.Nodes.Add(new object[] { item.Attribute("Name").Value, md });
                var gp = this.navMenu.Groups.Add();
                gp.Caption = item.Attribute("Name").Value;
                gp.Tag = md;
                CanAddMenuGrp(gp);
                foreach (XElement xd in item.Elements()) {
                    var mi = new MenuData {
                        IsUsing = true,
                        MenuGrpName = md.MenuGrpName,
                        MenuItem = new MenuItemData {
                            MenuAsmName = xd.Attribute("AsmName").Value,
                            MenuClsName = xd.Attribute("ClsName").Value,
                            MenuName = xd.Attribute("Name").Value,
                            IsUsing = string.Compare(true.ToString(), xd.Attribute("IsUsing").Value) == 0
                        }
                    };
                    var lnk = new DevExpress.XtraNavBar.NavBarItem(mi.MenuItem.MenuName);
                    gp.ItemLinks.Add(lnk);
                    lnk.Visible = CanAddLink(mi);
                    lnk.Tag = mi;
                }
            }

            //navMenu.Groups;
        }