コード例 #1
0
ファイル: frmPO.cs プロジェクト: dennryuu/GZFramework.Demo
        private void gv_Detail_ValidatingEditor(object sender, DevExpress.XtraEditors.Controls.BaseContainerValidateEditorEventArgs e)
        {
            var view = sender as DevExpress.XtraGrid.Views.Grid.GridView;

            if (Object.Equals(view.FocusedColumn.Tag, "NotNull"))
            {
                if (Object.Equals(string.Empty, e.Value) || Object.Equals(null, e.Value) || Object.Equals(DBNull.Value, e.Value))
                {
                    e.Valid     = false;
                    e.ErrorText = view.FocusedColumn.Caption + "不能为空!";
                }
            }
            if (view.FocusedColumn.FieldName == tb_PODetail.Qty || view.FocusedColumn.FieldName == tb_PODetail.POPrice)
            {
                decimal price = 0; int qty = 0;
                if (view.FocusedColumn.FieldName == tb_PODetail.Qty)
                {
                    price = ConvertLib.ToDecimal(view.GetFocusedDataRow()[tb_PODetail.POPrice], 0);
                    qty   = ConvertLib.ToInt(e.Value, 0);
                }
                else
                {
                    price = ConvertLib.ToDecimal(e.Value, 0);
                    qty   = ConvertLib.ToInt(view.GetFocusedDataRow()[tb_PODetail.Qty], 0);
                }



                decimal amount = price * qty;
                view.SetFocusedRowCellValue(tb_PODetail.TotalPOAmount, amount);
                RefreshSummary();
            }
        }
コード例 #2
0
        void refreshAmount()
        {
            int     qty   = ConvertLib.ToInt(txtQty.EditValue);
            decimal price = ConvertLib.ToDecimal(txtUnitPrice.EditValue, 0);

            txtTotalAmount.EditValue = qty * price;
        }
コード例 #3
0
ファイル: frmPO.cs プロジェクト: dennryuu/GZFramework.Demo
        /// <summary>
        /// 审核
        /// </summary>
        protected override void DoApproval(object sender)
        {
            DataRow row = gvMainData.GetFocusedDataRow();

            if (row == null)
            {
                return;
            }
            frmAppResult LoadResult = (frmAppResult)ConvertLib.ToInt(row["AppStatus"]);
            frmAppResult appstatus  = frmApp.ShowForm(LoadResult);

            if (appstatus != frmAppResult.未审核)
            {
                string docno = row[tb_PO.DocNo] + "";
                bll.Approval(docno, (int)appstatus);
                row[tb_PO.AppUser]   = Loginer.CurrentLoginer.Account;
                row[tb_PO.AppDate]   = DateTime.Now;
                row[tb_PO.AppStatus] = (int)appstatus;

                if (this.CurrentDataState == FormDataState.View)
                {
                    EditData.Tables[tb_PO._TableName].Rows[0][tb_PO.AppUser]   = Loginer.CurrentLoginer.Account;
                    EditData.Tables[tb_PO._TableName].Rows[0][tb_PO.AppDate]   = DateTime.Now;
                    EditData.Tables[tb_PO._TableName].Rows[0][tb_PO.AppStatus] = (int)appstatus;
                }

                row.AcceptChanges();
            }
        }
コード例 #4
0
ファイル: frmPO.cs プロジェクト: dennryuu/GZFramework.Demo
        bool validateApprove()
        {
            DataRow row = gvMainData.GetFocusedDataRow();
            bool    app = ConvertLib.ToInt(row[tb_PO.AppStatus]) != 0;

            return(app);
        }
コード例 #5
0
        private void BoundData(DataSet ds, string LayoutID)
        {
            DataTable dtDetail = ds.Tables[sys_GridViewLayoutDetail._TableName];

            DataRow row;

            foreach (GridColumn col in _View.Columns)
            {
                if (dtDetail.Select(String.Format("{0}='{1}'", sys_GridViewLayoutDetail.FileName, col.FieldName)).Length == 0)
                {
                    row = dtDetail.Rows.Add();

                    row[sys_GridViewLayoutDetail.LayoutID]      = LayoutID;
                    row[sys_GridViewLayoutDetail.FileName]      = col.FieldName;
                    row[sys_GridViewLayoutDetail.FileCaptionBK] = col.Caption;
                    row[sys_GridViewLayoutDetail.FileCaption]   = col.Caption;
                    row[sys_GridViewLayoutDetail.IsShow]        = col.Visible ? "Y" : "N";
                    row[sys_GridViewLayoutDetail.Width]         = col.Width;
                    row[sys_GridViewLayoutDetail.FontColor]     = col.AppearanceCell.ForeColor.ToArgb();
                    row[sys_GridViewLayoutDetail.BackColor]     = col.AppearanceCell.BackColor.ToArgb();
                    row[sys_GridViewLayoutDetail.Alignment]     = (int)col.AppearanceCell.TextOptions.HAlignment;
                    if (col.SummaryItem != null)
                    {
                        row[sys_GridViewLayoutDetail.SummaryType]   = (int)col.SummaryItem.SummaryType;
                        row[sys_GridViewLayoutDetail.SummaryFormat] = col.SummaryItem.DisplayFormat;
                    }
                }
            }

            gridControl1.DataSource     = ds.Tables[sys_GridViewLayoutDetail._TableName];
            dataBindingView1.DataSource = ds.Tables[sys_GridViewLayout._TableName];

            txt_HorzLineColor.Color = Color.FromArgb(ConvertLib.ToInt(ds.Tables[sys_GridViewLayout._TableName].Rows[0][sys_GridViewLayout.HorzLineColor]));
            txt_VertLineColor.Color = Color.FromArgb(ConvertLib.ToInt(ds.Tables[sys_GridViewLayout._TableName].Rows[0][sys_GridViewLayout.VertLineColor]));
        }
コード例 #6
0
        private static void LoadSummaryData(GridView gv, DataTable dt)
        {
            DataRow row = dt.Rows[0];

            //交替行颜色
            gv.OptionsView.EnableAppearanceEvenRow = gv.OptionsView.EnableAppearanceOddRow = Object.Equals(row[sys_GridViewLayout.IntervalColor], "Y");
            //标题高
            gv.ColumnPanelRowHeight = ConvertLib.ToInt(row[sys_GridViewLayout.HeadHeight], -1);
            //行高
            gv.RowHeight = ConvertLib.ToInt(row[sys_GridViewLayout.RowHeight], -1);
            //显示横线
            gv.OptionsView.ShowHorizontalLines = Object.Equals(row[sys_GridViewLayout.HorzLine], "Y") ? DefaultBoolean.True : DefaultBoolean.False;
            //显示竖线
            gv.OptionsView.ShowVerticalLines = Object.Equals(row[sys_GridViewLayout.VertLine], "Y") ? DefaultBoolean.True : DefaultBoolean.False;

            //横线颜色
            if (ConvertLib.ToInt(row[sys_GridViewLayout.HorzLineColor]) != 0)
            {
                gv.Appearance.HorzLine.BackColor = Color.FromArgb(ConvertLib.ToInt(row[sys_GridViewLayout.HorzLineColor]));
            }
            //竖线颜色
            if (ConvertLib.ToInt(row[sys_GridViewLayout.VertLineColor]) != 0)
            {
                gv.Appearance.VertLine.BackColor = Color.FromArgb(ConvertLib.ToInt(row[sys_GridViewLayout.VertLineColor]));
            }
        }
コード例 #7
0
        void RefreshNodeCheckState()
        {
            this.UncheckAll();
            if (_EditData == null)
            {
                return;
            }
            string Key;

            foreach (DataRow row in EditData.Rows)
            {
                int authority = ConvertLib.ToInt(row[dt_MyRoleAuthority.Authority]);
                var v         = ConvertLib.ToBinaryNums(authority);
                foreach (int i in v)
                {
                    Key = String.Format("{0}.{1}", row[dt_MyRoleAuthority.FunctionID], i);
                    TreeListNode node = this.FindNodeByKeyID(Key);
                    if (node == null)
                    {
                        continue;
                    }

                    _TreeListInitial.SetNodeCheckState(node, CheckState.Checked);
                }
            }
        }
コード例 #8
0
        public List <ModuleModel> GetModuleALL()
        {
            List <ModuleModel> lst = new List <ModuleModel>();
            var modules            = GetLocalAllModules();


            DataSet   ds           = new bllModules().GetUserModules(Loginer.CurrentLoginer.Account);
            DataTable dtModules    = ds.Tables[sys_Modules._TableName];
            DataTable dtModulesFun = ds.Tables[sys_ModulesFunction._TableName];


            foreach (IModule m in modules.Modules)
            {
                DataRow drModule = dtModules.Select($"{sys_Modules.ModuleID}='{m.ModuleID}'").FirstOrDefault();

                ModuleModel module = new ModuleModel()
                {
                    ModuleImg      = m.ModuleImg,
                    ModuleName     = m.ModuleName,
                    ModuleID       = m.ModuleID,
                    Sort           = -1,
                    ModuleMainType = (m is Form) ? m.GetType() : null
                };
                if (drModule != null)
                {
                    module.ModuleName = ConvertLib.ToString(drModule[sys_Modules.ModuleName]);
                    module.Sort       = ConvertLib.ToInt(drModule[sys_Modules.Sort]);
                    module.IsNew      = false;
                }

                foreach (ModuleFunction fun in m.FunctionCollection)
                {
                    fun.Sort = -1;
                    DataRow drFun = dtModulesFun.Select($"{sys_ModulesFunction.FunctionID}='{fun.FunctionID}'").FirstOrDefault();
                    if (drFun != null)
                    {
                        fun.FunctionName = ConvertLib.ToString(drFun[sys_ModulesFunction.FunctionName]);
                        fun.Sort         = ConvertLib.ToInt(drFun[sys_ModulesFunction.Sort]);
                        byte[] imgByte = drFun[sys_ModulesFunction.Image] as byte[];
                        if (imgByte != null && imgByte.Length > 0)
                        {
                            fun.FormIcon = Common.ImageLibrary.ConvertBytesToImage(imgByte);
                        }
                        fun.IsNew = false;
                    }

                    fun.UserAuthority = GZFramework.UI.Core.FunctionAuthority.All;

                    module.functions.Add(fun);
                }
                if (module.functions.Count > 0)
                {
                    lst.Add(module);
                }
            }
            SortModule(lst);
            return(lst);
        }
コード例 #9
0
        void UpdateAuthority(TreeListNode Node)
        {
            if (Node.HasChildren)
            {
                foreach (TreeListNode Cnode in Node.Nodes)
                {
                    UpdateAuthority(Cnode);
                }
            }
            else
            {
                if (Node.Checked)
                {
                    if (ConvertLib.ToInt(Node.GetValue("AuthorityID")) <= 0)
                    {
                        return;
                    }
                    string  filter = String.Format("{0}='{1}'", dt_MyRoleAuthority.FunctionID, Node.GetValue("ParentKey"));
                    var     v      = EditData.Tables[dt_MyRoleAuthority._TableName].Select(filter);
                    DataRow dr;
                    if (v.Length > 0)
                    {
                        dr = v[0];
                        dr[dt_MyRoleAuthority.Authority] = ConvertLib.ToInt(dr[dt_MyRoleAuthority.Authority]) + ConvertLib.ToInt(Node.GetValue("AuthorityID"));
                    }
                    else
                    {
                        dr = EditData.Tables[dt_MyRoleAuthority._TableName].Rows.Add();
                        dr[dt_MyRoleAuthority.RoleID]     = EditData.Tables[dt_MyRole._TableName].Rows[0][dt_MyRole.RoleID];
                        dr[dt_MyRoleAuthority.FunctionID] = Node.GetValue("ParentKey");
                        dr[dt_MyRoleAuthority.Authority]  = Node.GetValue("AuthorityID");
                    }
                }
                else
                {
                    string filter = String.Format("{0}='{1}'", dt_MyRoleAuthority.FunctionID, Node.GetValue("ParentKey"));
                    //string stringFormat = String.Format("{0}='{1}' AND {2}='{3}'",
                    //                    dt_MyRoleAuthority.FunctionID, Node.GetValue("ParentKey"), dt_MyRoleAuthority.Authority, Node.GetValue("AuthorityID"));
                    DataRow[] drs = EditData.Tables[dt_MyRoleAuthority._TableName].Select(filter);
                    if (drs.Length > 0)
                    {
                        int authority = 0;
                        if (drs.Length > 0)
                        {
                            authority = ConvertLib.ToInt(drs[0][dt_MyRoleAuthority.Authority]);
                        }

                        int NoteValue = ConvertLib.ToInt(Node.GetValue("AuthorityID"));

                        if ((authority & NoteValue) == NoteValue)//包含权限
                        {
                            drs[0][dt_MyRoleAuthority.Authority] = authority - NoteValue;
                        }
                    }
                }
            }
        }
コード例 #10
0
 private void btn_OK_Click(object sender, EventArgs e)
 {
     Num = ConvertLib.ToInt(txtNum.EditValue);
     if (Num <= 0)
     {
         Msg.Warning("数量必须大于0");
         return;
     }
     DialogResult = DialogResult.Cancel;
 }
コード例 #11
0
        protected frmApp(DataRow row)
        {
            dr = row;
            frmAppResult LoadResult = (frmAppResult)ConvertLib.ToInt(row["AppStatus"]);

            InitializeComponent();
            btn_Access.Enabled = LoadResult == frmAppResult.未审核;
            btn_Abort.Enabled  = LoadResult == frmAppResult.已审核;
            btn_Stop.Enabled   = LoadResult == frmAppResult.未审核;
        }
コード例 #12
0
        private void btn_OK_Click(object sender, EventArgs e)
        {
            bool b = LibraryTools.IsNotEmpBaseEdit(txtItemNo, "货号不能为空!");

            if (b == false)
            {
                return;
            }
            Data = new DataTable();
            Data.Columns.Add(nameof(tb_PODetail.ItemNo), typeof(System.String));
            Data.Columns.Add(nameof(tb_PODetail.ItemName), typeof(System.String));
            Data.Columns.Add(nameof(tb_PODetail.CategoryID), typeof(System.String));
            Data.Columns.Add(nameof(tb_PODetail.POPrice), typeof(System.Decimal));
            Data.Columns.Add(nameof(tb_PODetail.SOPrice), typeof(System.Decimal));
            Data.Columns.Add(nameof(tb_PODetail.Color), typeof(System.String));
            Data.Columns.Add(nameof(tb_PODetail.Size), typeof(System.String));
            Data.Columns.Add(nameof(tb_PODetail.Qty), typeof(System.Int16));
            Data.Columns.Add(nameof(tb_PODetail.TotalPOAmount), typeof(System.Decimal));
            foreach (DataRow row in dtQty.Rows)
            {
                string color = ConvertLib.ToString(row["Color"]);
                for (int i = 0; i < dtSize.Rows.Count; i++)
                {
                    string fileName = "Qty_" + (i + 1);
                    int    qty      = ConvertLib.ToInt(row[fileName]);
                    if (qty > 0)
                    {
                        DataRow dr = Data.NewRow();


                        dr[tb_PODetail.ItemNo] = txtItemNo.EditValue;
                        if (!String.IsNullOrEmpty(ConvertLib.ToString(txtItemName.EditValue)))
                        {
                            dr[tb_PODetail.ItemName] = txtItemName.EditValue;
                        }
                        dr[tb_PODetail.CategoryID] = txtCategory.EditValue;
                        if (!String.IsNullOrEmpty(ConvertLib.ToString(txtPOPrice.EditValue)))
                        {
                            dr[tb_PODetail.POPrice] = txtPOPrice.EditValue;
                        }
                        if (!String.IsNullOrEmpty(ConvertLib.ToString(txtSOPrice.EditValue)))
                        {
                            dr[tb_PODetail.SOPrice] = txtSOPrice.EditValue;
                        }
                        dr[tb_PODetail.Color]         = color;
                        dr[tb_PODetail.Size]          = dtSize.Rows[i]["DataName"];
                        dr[tb_PODetail.Qty]           = qty;
                        dr[tb_PODetail.TotalPOAmount] = ConvertLib.ToDecimal(txtPOPrice.EditValue, 0) * qty;
                        Data.Rows.Add(dr);
                    }
                }
            }
            Data.AcceptChanges();
            this.DialogResult = DialogResult.OK;
        }
コード例 #13
0
        private List <ModuleModel> GetModuleConfig()
        {
            List <ModuleModel> lst = new List <ModuleModel>();
            var lstModules         = GetLocalAllModules();

            DataSet   ds           = new bllModules().GetUserModules(Loginer.CurrentLoginer.Account);
            DataTable dtModules    = ds.Tables[sys_Modules._TableName];
            DataTable dtModulesFun = ds.Tables[sys_ModulesFunction._TableName];

            foreach (DataRow dr in dtModules.Rows)
            {
                var m = lstModules.Modules[dr[sys_Modules.ModuleID].ToString()];
                if (m == null)
                {
                    continue;
                }

                ModuleModel module = new ModuleModel()
                {
                    ModuleImg      = m.ModuleImg,
                    ModuleName     = dr[sys_Modules.ModuleName] + "",
                    ModuleID       = m.ModuleID,
                    Sort           = ConvertLib.ToInt(dr[sys_Modules.Sort]),
                    IsNew          = false,
                    ModuleMainType = (m is Form) ? m.GetType() : null
                };

                dtModulesFun.DefaultView.RowFilter = String.Format("{0}='{1}'", sys_ModulesFunction.ModuleID, dr[sys_Modules.ModuleID]);
                foreach (DataRow row in dtModulesFun.DefaultView.ToTable().Rows)
                {
                    var fun = m.FunctionCollection[row[sys_ModulesFunction.FunctionID].ToString()];
                    fun.UserAuthority = ConvertLib.ToInt(row["UserAuthority"]);
                    fun.FunctionName  = ConvertLib.ToString(row[sys_ModulesFunction.FunctionName]);
                    fun.Sort          = ConvertLib.ToInt(row[sys_ModulesFunction.Sort]);
                    fun.IsNew         = false;
                    byte[] imgByte = row[sys_ModulesFunction.Image] as byte[];
                    if (imgByte != null && imgByte.Length > 0)
                    {
                        fun.FormIcon = Common.ImageLibrary.ConvertBytesToImage(imgByte);
                    }
                    if (fun == null)
                    {
                        continue;
                    }
                    module.functions.Add(fun);
                }
                if (module.functions.Count > 0)
                {
                    lst.Add(module);
                }
            }
            SortModule(lst);
            return(lst);
        }
コード例 #14
0
        void Find()
        {
            DataTable dt = bllpi.SearchDataBarCode(txt_ProductCode.Text);
            DataRow   row;

            if (dt.Rows.Count != 1)
            {
                row = Dialog.frmDialogProducQty.ShowForm(txt_ProductCode.Text, dt);
            }
            else
            {
                row = dt.Rows[0];
            }
            //DataRow row = Dialog.frmDialogProducQty.ShowForm(txt_ProductCode.Text);
            if (row != null)
            {
                var al = EditData.Tables[tb_SODetail._TableName].Select($"{tb_SODetail.BarCode}='{row[tb_ProductInventory.BarCode]}'").FirstOrDefault();
                if (al != null)
                {
                    int newQty = ConvertLib.ToInt(al[tb_SODetail.Qty]) + 1;
                    al[tb_SODetail.Qty]         = newQty;
                    al[tb_SODetail.TotalAmount] = ConvertLib.ToDecimal(al[tb_SODetail.UnitPrice], 0) * newQty;
                }
                else
                {
                    DataRow dr = EditData.Tables[tb_SODetail._TableName].NewRow();
                    dr[tb_SODetail.BarCode]     = row[tb_ProductInventory.BarCode];
                    dr[tb_SODetail.ItemNo]      = row[tb_ProductInventory.ItemNo];
                    dr[tb_SODetail.ItemName]    = row[tb_ProductInventory.ItemName];
                    dr[tb_SODetail.CategoryID]  = row[tb_ProductInventory.CategoryID];
                    dr[tb_SODetail.Color]       = row[tb_ProductInventory.Color];
                    dr[tb_SODetail.Size]        = row[tb_ProductInventory.Size];
                    dr[tb_SODetail.Qty]         = 1;
                    dr[tb_SODetail.UnitPrice]   = row[tb_ProductInventory.SOPrice];
                    dr[tb_SODetail.TotalAmount] = ConvertLib.ToDecimal(row[tb_ProductInventory.SOPrice], 0) * 1;
                    EditData.Tables[tb_SODetail._TableName].Rows.Add(dr);
                    gvSummary.ClearSelection();
                    gvSummary.SelectRow(gvSummary.RowCount - 1);
                    gvSummary.FocusedRowHandle = gvSummary.RowCount - 1;
                }
                txt_ProductCode.EditValue = "";
                refreshTotalMsg();
            }
        }
コード例 #15
0
 private void UcAppStatus_EditValueChanged(object sender, EventArgs e)
 {
     if (ConvertLib.ToInt(this.EditValue) == 0)
     {
         this.Properties.Appearance.ForeColor = System.Drawing.Color.FromArgb(99, 99, 99);
     }
     if (ConvertLib.ToInt(this.EditValue) == -1)
     {
         this.Properties.Appearance.ForeColor = System.Drawing.Color.Brown;
     }
     if (ConvertLib.ToInt(this.EditValue) == 1)
     {
         this.Properties.Appearance.ForeColor = System.Drawing.Color.Green;
     }
     if (ConvertLib.ToInt(this.EditValue) == 2)
     {
         this.Properties.Appearance.ForeColor = System.Drawing.Color.DarkViolet;
     }
 }
コード例 #16
0
        private static void LoadDetailData(GridView gv, DataTable dt)
        {
            bool ShowFoot         = false;
            List <GridColumn> lst = new List <GridColumn>();

            foreach (GridColumn col in gv.Columns)
            {
                var drs = dt.Select(String.Format("{0}='{1}'", sys_GridViewLayoutDetail.FileName, col.FieldName));
                if (drs.Length > 0)
                {
                    DataRow row = drs[0];
                    col.Caption = ConvertLib.ToString(row[sys_GridViewLayoutDetail.FileCaption]);
                    col.Visible = Object.Equals(row[sys_GridViewLayoutDetail.IsShow], "Y");
                    if (col.Visible == false)
                    {
                        lst.Add(col);
                    }
                    col.Width = ConvertLib.ToInt(row[sys_GridViewLayoutDetail.Width], 75);
                    col.AppearanceCell.ForeColor = Color.FromArgb(ConvertLib.ToInt(row[sys_GridViewLayoutDetail.FontColor]));
                    col.AppearanceCell.BackColor = Color.FromArgb(ConvertLib.ToInt(row[sys_GridViewLayoutDetail.BackColor]));

                    int alignmeng = ConvertLib.ToInt(row[sys_GridViewLayoutDetail.Alignment]);
                    col.AppearanceCell.TextOptions.HAlignment = (HorzAlignment)alignmeng;

                    if (ConvertLib.ToInt(row[sys_GridViewLayoutDetail.SummaryType], 6) != 6)
                    {
                        ShowFoot = true;
                        col.Summary.Clear();
                        var item = col.Summary.Add();
                        item.FieldName     = col.FieldName;
                        item.SummaryType   = (SummaryItemType)ConvertLib.ToInt(row[sys_GridViewLayoutDetail.SummaryType]);
                        item.DisplayFormat = ConvertLib.ToString(row[sys_GridViewLayoutDetail.SummaryFormat]);
                    }
                }
            }
            foreach (GridColumn col in lst)
            {
                gv.Columns.Remove(col);
            }
            gv.OptionsView.ShowFooter = ShowFoot;
        }
コード例 #17
0
        void UpdateAuthority(TreeListNode Node)
        {
            if (EditData == null)
            {
                return;
            }

            if (Node.HasChildren)
            {
                foreach (TreeListNode Cnode in Node.Nodes)
                {
                    UpdateAuthority(Cnode);
                }
            }
            else
            {
                if (ConvertLib.ToInt(Node.GetValue("AuthorityID")) <= 0)
                {
                    return;
                }
                string filter = String.Format("{0}='{1}'", sys_ModulesFunctionAuthority.FunctionID, Node.GetValue("ParentKey"));
                var    v      = EditData.Select(filter);

                if (Node.Checked)
                {
                    DataRow dr;
                    if (v.Length > 0)
                    {
                        dr = v[0];
                        dr[dt_MyRoleAuthority.Authority] = ConvertLib.ToInt(dr[dt_MyRoleAuthority.Authority]) + ConvertLib.ToInt(Node.GetValue("AuthorityID"));
                    }
                    else
                    {
                        dr = EditData.Rows.Add();
                        dr[dt_MyRoleAuthority.FunctionID] = Node.GetValue("ParentKey");
                        dr[dt_MyRoleAuthority.Authority]  = Node.GetValue("AuthorityID");
                        if (AddDataRow != null)
                        {
                            AddDataRow(this, new ArgsAddDataRow(dr));
                        }
                    }
                }
                else
                {
                    if (v.Length > 0)
                    {
                        int authority = 0;
                        if (v.Length > 0)
                        {
                            authority = ConvertLib.ToInt(v[0][dt_MyRoleAuthority.Authority]);
                        }

                        int NoteValue = ConvertLib.ToInt(Node.GetValue("AuthorityID"));

                        if ((authority & NoteValue) == NoteValue)//包含权限
                        {
                            v[0][dt_MyRoleAuthority.Authority] = authority - NoteValue;
                        }
                    }
                }
            }
        }
コード例 #18
0
        public string DoGetDocSN(IDatabase db, ModelDocNo Model)
        {
            SqlParameterProvider p = new SqlParameterProvider();

            p.AddParameter("@DocCode", SqlDbType.VarChar, 50, Model.DocCode);
            string sql = "SELECT * FROM sys_DataSN WHERE DocCode=@DocCode";

            DataTable dt        = db.GetTable(sql, "", p);
            string    DocHeader = "";
            string    DocType   = "";
            string    Separate  = "";
            int       Length    = 0;

            if (dt.Rows.Count > 0)
            {
                DocHeader = ConvertLib.ToString(dt.Rows[0][sys_DataSN.DocHeader]);
                DocType   = ConvertLib.ToString(dt.Rows[0][sys_DataSN.DocType]);
                Separate  = ConvertLib.ToString(dt.Rows[0][sys_DataSN.Separate]);
                Length    = ConvertLib.ToInt(dt.Rows[0][sys_DataSN.Length]);
            }
            else
            {
                AddDocSNRule(db, Model);
                DocHeader = Model.DocHeader;
                DocType   = Model.DocRule;
                Separate  = Model.Separate;
                Length    = Model.Length;
            }

            string DocSeed = "";

            switch (DocType.ToUpper())
            {
            case "YEAR":
                DocSeed   = DateTime.Now.Year.ToString();
                DocHeader = DocHeader + DocSeed;
                break;

            case "YEAR-MONTH":
                DocSeed   = DateTime.Now.ToString("yyyyMM");
                DocHeader = DocHeader + DocSeed;
                break;

            case "YEAR-MONTH-DD":
                DocSeed   = DateTime.Now.ToString("yyyyMMdd");
                DocHeader = DocHeader + DocSeed;
                break;

            case "UP":
                DocSeed = Model.DocCode;
                break;

            case "CUSTOMER":
                DocSeed = Model.CustomerSeed;
                break;
            }


            int    snindex          = 0;
            string sql2             = "SELECT * FROM sys_DataSNDetail WHERE DocCode=@DocCode AND Seed=@Seed";
            SqlParameterProvider p2 = new SqlParameterProvider();

            p2.AddParameter("@DocCode", SqlDbType.VarChar, 50, Model.DocCode);
            p2.AddParameter("@Seed", SqlDbType.VarChar, 50, DocSeed);
            DataTable datasn = db.GetTable(sql2, "t", p2);

            if (datasn.Rows.Count > 0)
            {
                snindex = ConvertLib.ToInt(datasn.Rows[0]["MaxID"]);
                snindex = ValidateSN(snindex + 1);

                string sql3             = "UPDATE sys_DataSNDetail SET MaxID=@Value WHERE DocCode=@DocCode AND Seed=@Seed";
                SqlParameterProvider p3 = new SqlParameterProvider();
                p3.AddParameter("@Value", SqlDbType.Int, snindex);
                p3.AddParameter("@DocCode", SqlDbType.VarChar, 50, Model.DocCode);
                p3.AddParameter("@Seed", SqlDbType.VarChar, 50, DocSeed);
                db.ExecuteNonQuery(sql3, p3);
            }
            else
            {
                snindex = ValidateSN(1);
                string sql4             = "INSERT INTO sys_DataSNDetail(DocCode,Seed,MaxID) VALUES(@DocCode, @Seed, @Value)";
                SqlParameterProvider p4 = new SqlParameterProvider();
                p4.AddParameter("@Value", SqlDbType.Int, snindex);
                p4.AddParameter("@DocCode", SqlDbType.VarChar, 50, Model.DocCode);
                p4.AddParameter("@Seed", SqlDbType.VarChar, 50, DocSeed);
                db.ExecuteNonQuery(sql4, p4);
            }
            string snvalue = snindex.ToString().PadLeft(Length, '0');

            if (DocType.ToUpper() == "CUSTOMER")
            {
                return(DocHeader + snvalue);
            }
            else
            {
                return(DocHeader + Separate + snvalue);
            }
        }