示例#1
0
 public static void CheckCheckListBox(DevExpress.XtraEditors.CheckedListBoxControl checkListBox, string tableName, string fieldName, string whereStr)
 {
     int i = 0;
     while (i < checkListBox.ItemCount)
     {
         checkListBox.SetItemCheckState(i, ((Services.Database.SelectFieldValue(tableName, fieldName, whereStr + checkListBox.GetItemValue(i).ToString() + "'") != null) ? CheckState.Checked : CheckState.Unchecked));
         i = i + 1;
     }
 }
示例#2
0
        private void SetCheckedListValue(DevExpress.XtraEditors.CheckedListBoxControl control,string strSQL,string target)
        {
            //Clear Item List
            control.Refresh();
            for (int i=0;i<control.Items.Count;i++)
                control.SetItemChecked(i,false);

            DataSet _ds = new DataSet();
            SqlHelper.FillDataset(connection,CommandType.StoredProcedure,"UP_GETDATA",_ds,new string[] {"table"}, new SqlParameter("@strSQL", strSQL) );

            DataView dv;
            dv = _ds.Tables["table"].DefaultView;

            //set check value
            try
            {
                for (int i=0; i< dv.Count; i++ )
                {
                    for (int j=0; j<control.ItemCount; j++)
                    {
                        if (dv[i].Row[target].ToString()== control.GetItemValue(j).ToString())
                        {
                            control.SetItemChecked(j,true);
                            break;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
示例#3
0
        public static void SaveCheckListBox(DevExpress.XtraEditors.CheckedListBoxControl CheckListBox, string Tablename, string LinkFieldvalue, string LinkFieldName, string FieldName, string KeyFieldName, string SeqName, SecurityService.UserInfo userInfo, ref List<string> SqlList)
        {
            try
            {
                if (LinkFieldvalue != null)
                {
                    SqlList.Add("Delete " + Tablename + " Where " + LinkFieldName + " = '" + LinkFieldvalue + "'");
                    int i = 0;

                    while (i < CheckListBox.ItemCount)
                    {
                        if (CheckListBox.GetItemCheckState(i) == CheckState.Checked)
                        {
                            string ID = "";
                            string[] fields = { LinkFieldName, FieldName, LinkFieldvalue, CheckListBox.GetItemValue(i).ToString() };

                            SqlList.Add(Services.Database.SaveTableData(Tablename, KeyFieldName, ref ID, SeqName, userInfo.LoginUserName, fields));
                        }
                        i = i + 1;
                    }
                }
            }
            catch (Exception Err)
            {
                MessageBox.Show("Дараахи алдаа гарлаа : " + Err.Message.ToString(), "Алдаа", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }