日韩黑丝制服一区视频播放|日韩欧美人妻丝袜视频在线观看|九九影院一级蜜桃|亚洲中文在线导航|青草草视频在线观看|婷婷五月色伊人网站|日本一区二区在线|国产AV一二三四区毛片|正在播放久草视频|亚洲色图精品一区

分享

頁(yè)面公用數(shù)據(jù)加載,不需要數(shù)據(jù)庫(kù)交互,提高瀏覽速度

 冰泛 2012-10-09
          private List<ComboBoxItem> CustList = null, StorList = null, AreaList = null;獲取
        ComboBoxItem custItem = null;
cbxStorage.SelectedIndexChanged -= new EventHandler(cbxStorage_SelectedIndexChanged);  
            if (Session.ExistKey("Storages"))
            {
                this.StorList = Session.GetValue("Storages") as List<ComboBoxItem>;
            }
            else
            {
                ComboBoxItem[] _storages = dataService.Storage_GetStorageDataList(login.loginKey, Convert.ToInt32(login.userInfo.CompanyID));
                if (_storages != null)
                {
                    this.StorList = _storages.ToList<ComboBoxItem>();
                }
                if (this.StorList != null)
                {
                    Session.SetValue("Storages", this.StorList);
                }
            }
            Utility.InitComboxBox(cbxStorage, StorList);
            if (Session.ExistKey("Customers"))
            {
                this.CustList = Session.GetValue("Customers") as List<ComboBoxItem>;
            }
            else
            {
                ComboBoxItem[] _customers = dataService.Customer_GetCustomerDataList(login.loginKey);
                if (_customers != null)
                {
                    this.CustList = _customers.ToList<ComboBoxItem>();
                }
                if (this.CustList != null)
                {
                    Session.SetValue("Customers", this.CustList);
                }
            }
            Utility.InitComboxBox(cbxCustomer, CustList);
private void cbxStorage_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (cbxStorage.SelectedValue != null ||!cbxStorage.SelectedText.Equals("")) return;
            if (Session.ExistKey("Areas" + cbxStorage.SelectedValue))
            {
                this.AreaList = Session.GetValue("Areas" + cbxStorage.SelectedValue) as List<ComboBoxItem>;
            }
            else
            {
                dataService = new IMLZ_Storage.DataService.DataService();
                this.AreaList = dataService.Area_GetAreasDataListByStorage(login.loginKey, Convert.ToInt32(login.userInfo.CompanyID), Convert.ToInt32(cbxStorage.SelectedValue)).ToList<ComboBoxItem>();
                if (this.AreaList != null)
                {
                    Session.SetValue("Areas" + cbxStorage.SelectedValue, this.AreaList);
                }
            }
            Utility.InitComboxBox(cbxArea, this.AreaList);
}
//cbxCustomer.DataSource = custMan.seleCustomer(login.loginKey);
            //cbxCustomer.ValueMember = "id";
            //cbxCustomer.DisplayMember = "fullName";
            //cbxCustomer.SelectedIndex = -1;
                    
            //cbxStorage.DataSource = dataSer.StorageList_GetStorageListDataList(login.loginKey, Convert.ToInt32(login.userInfo.CompanyID));
            //cbxStorage.ValueMember = "StorageID";
            //cbxStorage.DisplayMember = "StorageName";
            //cbxStorage.SelectedIndex = -1;
/*
 * 作者:呂詩(shī)超
 * 日期:2012年5月
 */
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using IMLZ_Storage.DataService;
namespace IMLZ_Storage.App
{
    public class Utility
    {
        private static string[] actionList = null;
        private static string[] ActionList
        {
            get
            {
                if (actionList == null)
                {
                    actionList = Session.GetValue("ActionList") as string[];
                }
                return actionList;
            }
        }
        public static bool Verify(string actionName)
        {
            return !ActionList.Contains<string>(actionName);
        }
        public static ComboBoxItem GetComboBoxSelectedItemByCode(ComboBox comboBox, List<ComboBoxItem> items)
        {
            if (comboBox == null || items == null) return null;
            for (int i = 0, count = comboBox.Items.Count; i < count; i++)
            {
                if (comboBox.Text.Trim().ToUpper().Equals(items[i].Code.Trim().ToUpper()) || comboBox.Text.Trim().ToUpper().Equals(items[i].FormatText.Trim().ToUpper()) || comboBox.Text.Trim().ToUpper().Equals(items[i].Text.Trim().ToUpper()) || items[i].Text.Trim().ToUpper().IndexOf(comboBox.Text.Trim().ToUpper()) >= 0)
                {
                    comboBox.Text = items[i].FormatText;
                    return items[i];
                }
            }
            return null;
        }
        public static ComboBoxItem GetComboBoxSelectedItemByID(ComboBox comboBox, List<ComboBoxItem> items, int id)
        {
            if (comboBox == null || items == null) return null;
            for (int i = 0, count = comboBox.Items.Count; i < count; i++)
            {
                if (items[i].ID == id)
                {
                    comboBox.Text = items[i].FormatText;
                    return items[i];
                }
            }
            return null;
        }
        public static ComboBoxItem GetComboBoxSelectedItemByText(ComboBox comboBox, List<ComboBoxItem> items, string text)
        {
            if (comboBox == null || items == null) return null;
            for (int i = 0, count = comboBox.Items.Count; i < count; i++)
            {
                if (items[i].Text == text)
                {
                    comboBox.Text = items[i].FormatText;
                    return items[i];
                }
            }
            return null;
        }
        public static ComboBoxItem GetComboBoxSelectedItemByIndex(ComboBox comboBox, List<ComboBoxItem> items)
        {
            if (comboBox == null || items == null) return null;
            comboBox.Text = items[comboBox.SelectedIndex].FormatText;
            return items[comboBox.SelectedIndex];
        }
        public static void InitComboxBox(ComboBox comboBox, List<ComboBoxItem> items)
        {
            if (comboBox == null || items == null) return;
            comboBox.Items.Clear();
            for (int i = 0, count = items.Count; i < count; i++)
            {
                comboBox.Items.Add(items[i].FormatText);
            }
            comboBox.Text = string.Empty;
        }
        public static ComboBoxItem GetComboBoxItemByID(List<ComboBoxItem> items, int id)
        {
            if (items == null) return null;
            for (int i = 0, count = items.Count; i < count; i++)
            {
                if (items[i].ID == id)
                {
                    return items[i];
                }
            }
            return null;
        }
        public static object SumTableColumnValues(System.Data.DataTable table, string fieldName)
        {
            if (table == null || !table.Columns.Contains(fieldName)) return 0M;
            decimal sum = 0M;
            for (int i = 0, count = table.Rows.Count; i < count; i++)
            {
                sum += decimal.Parse(table.Rows[i][fieldName].ToString());
            }
            return sum;
        }
        public static string DecimalToCNNumber(decimal value)
        {
            string result = string.Empty;
            string[] number = { "零", "壹", "貳", "叁", "肆", "伍", "陸", "柒", "捌", "玖", "點(diǎn)" };
            string s = value.ToString("0萬(wàn)0仟0佰0拾0萬(wàn)0仟0佰0拾0萬(wàn)0仟0佰0拾0億0仟0佰0拾0萬(wàn)0仟0佰0拾0.000");
            string s2 = System.Text.RegularExpressions.Regex.Replace(s, @"^(0[億萬(wàn)仟佰拾]){0,}", "");
            s2 = System.Text.RegularExpressions.Regex.Replace(s, @"(0[億萬(wàn)仟佰拾])+", "0");
            s2 = System.Text.RegularExpressions.Regex.Replace(s2, @"^0", "");
            result = s2.Replace("0", number[0])
                       .Replace("1", number[1])
                       .Replace("2", number[2])
                       .Replace("3", number[3])
                       .Replace("4", number[4])
                       .Replace("5", number[5])
                       .Replace("6", number[6])
                       .Replace("7", number[7])
                       .Replace("8", number[8])
                       .Replace("9", number[9])
                       .Replace(".", number[10]);
            return result;
        }
        public static void ResetTableRowNo(System.Data.DataTable table)
        {
            if (table == null) return;
            int i = 0, count = table.Rows.Count;
            while (i < count)
            {
                table.Rows[i++]["RowNo"] = i;
            }
        }
        public static void ResetTableRowNo(System.Data.DataTable table, string rowNoFieldNamne)
        {
            if (table == null) return;
            int i = 0, count = table.Rows.Count;
            while (i < count)
            {
                table.Rows[i++][rowNoFieldNamne] = i;
            }
        }
        public static void ResetDataGridViewRowNo(DataGridView table)
        {
            if (table == null) return;
            int i = 0, count = table.Rows.Count;
            while (i < count)
            {
                table.Rows[i++].Cells["RowNo"].Value = i;
            }
        }
        public static void ResetDataGridViewRowNo(DataGridView table, string rowNoFieldNamne)
        {
            if (table == null) return;
            int i = 0, count = table.Rows.Count;
            while (i < count)
            {
                table.Rows[i++].Cells[rowNoFieldNamne].Value = i;
            }
        }
        public static void SetTableColumnValue(System.Data.DataTable table, string columnName, object columnValue)
        {
            if (table == null) return;
            for (int i = 0; i < table.Rows.Count; i++)
            {
                table.Rows[i][columnName] = columnValue;
            }
        }
        public static void SignDataGridViewRows(DataGridView grid, string columnName, string conumnValue, System.Drawing.Color backColor)
        {
            if (grid == null || !grid.Columns.Contains(columnName)) return;
            int i = -1;
            int count = grid.Rows.Count;
            while (++i < count)
            {
                if (grid.Rows[i].Cells[columnName].Value.ToString().Equals(conumnValue)) grid.Rows[i].DefaultCellStyle.BackColor = backColor;
            }
        }
        public static void SignDataGridViewRows(DataGridView grid, string columnName, Dictionary<string, System.Drawing.Color> columnValueColors)
        {
            if (grid == null || !grid.Columns.Contains(columnName) || columnValueColors == null) return;
            int i = -1;
            int count = grid.Rows.Count;
            while (++i < count)
            {
                foreach (var column in columnValueColors)
                {
                    if (grid.Rows[i].Cells[columnName].Value.ToString().Equals(column.Key)) grid.Rows[i].DefaultCellStyle.BackColor = column.Value;
                }
            }
        }
        public static void Clipboard_KeyEvent(object sender, KeyEventArgs e)
        {
            if (e.Control && e.KeyCode == Keys.C)
            {
                DataGridView grid = (DataGridView)sender;
                if (grid != null)
                {
                    string value = grid.CurrentCell.Value != null ? grid.CurrentCell.Value.ToString() : "";
                    Clipboard.SetText(value);
                }
            }
        }
    }
}

    本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶(hù)發(fā)布,不代表本站觀(guān)點(diǎn)。請(qǐng)注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購(gòu)買(mǎi)等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊一鍵舉報(bào)。
    轉(zhuǎn)藏 分享 獻(xiàn)花(0

    0條評(píng)論

    發(fā)表

    請(qǐng)遵守用戶(hù) 評(píng)論公約

    類(lèi)似文章 更多