protected override void ShowForm() { this.FillCombo(); HPS.BLL.ComputerBLL.BLLComputer_TFactory ComputerFactory = new HPS.BLL.ComputerBLL.BLLComputer_TFactory(); HPS.BLL.ComputerBLL.BLLComputer_T ComputerEntity = ComputerFactory.GetBy((HPS.BLL.ComputerBLL.BLLComputer_TKeys)Key); if (ComputerEntity == null) { throw new HPS.Exceptions.ComputerNotFound(); } MessageLED_nvcTextBox.Text = Hepsa.Core.Common.PersentationController.GetEntityValue(ComputerEntity.MessageLED_nvc, TypeCode.String).ToString(); IPTextBox.Text = Hepsa.Core.Common.PersentationController.GetEntityValue(ComputerEntity.IPAddress_nvc, TypeCode.String).ToString(); MacTextBox.Text = Hepsa.Core.Common.PersentationController.GetEntityValue(ComputerEntity.MacAddress_nvc, TypeCode.String).ToString(); Active_bitCheckBox.Checked = (Boolean)Hepsa.Core.Common.PersentationController.GetEntityValue(ComputerEntity.Active_bit, TypeCode.Boolean); List <HPS.BLL.ComputerBLL.BLLComputer_T> ComputerList = new List <HPS.BLL.ComputerBLL.BLLComputer_T>(); ComputerList = ComputerFactory.GetAllByCondition(string.Format(" Computer_T.MacAddress_nvc='{0}' AND Deleted_bit=0", _MacAddress_nvc)); if (ComputerList.Count > 0) { foreach (var item in ComputerList) { foreach (var gridRow in UserNameGridView.GetRows()) { if (item.Computer_nvc == gridRow.Cells["username_nvc"].Value.ToString()) { gridRow.IsChecked = true; } } } } }
protected override void Insert() { HPS.BLL.ComputerBLL.BLLComputer_TFactory ComputerFactory = new HPS.BLL.ComputerBLL.BLLComputer_TFactory(); try { HPS.BLL.ComputerBLL.BLLComputer_T ComputerEntity = new HPS.BLL.ComputerBLL.BLLComputer_T(); List <BLL.ComputerBLL.BLLComputer_T> ComputerList = new List <BLL.ComputerBLL.BLLComputer_T>(); ComputerList = ComputerFactory.GetAllByCondition("MacAddress_nvc=N'" + MacTextBox.Text + "'"); BLL.ComputerBLL.BLLComputer_TKeys ComputerKey = new BLL.ComputerBLL.BLLComputer_TKeys(); foreach (Janus.Windows.GridEX.GridEXRow item in UserNameGridView.GetCheckedRows()) { if (ComputerList.Find(a => a.Computer_nvc == item.Cells["username_nvc"].Value.ToString() && a.Deleted_bit == false && a.MacAddress_nvc == MacTextBox.Text) == null) { ComputerEntity.ComputerID_int = null; ComputerEntity.Computer_nvc = item.Cells["username_nvc"].Value.ToString(); ComputerEntity.IPAddress_nvc = Hepsa.Core.Common.PersentationController.GetEntityValue(IPTextBox.Text, TypeCode.String).ToString(); ComputerEntity.MacAddress_nvc = Hepsa.Core.Common.PersentationController.GetEntityValue(MacTextBox.Text, TypeCode.String).ToString(); ComputerEntity.MessageLED_nvc = Hepsa.Core.Common.PersentationController.GetEntityValue(MessageLED_nvcTextBox.Text, TypeCode.String).ToString(); ComputerEntity.Active_bit = Active_bitCheckBox.Checked; ComputerEntity.UserGroupID_int = (Int32)item.Cells["UserGroupID_int"].Value; ComputerFactory.BeginProc(); ComputerFactory.Insert(ComputerEntity); ComputerFactory.CommitProc(); } } //if (DataTable != null) //{ // DataRow dr = this.DataTable.NewRow(); // dr[HPS.BLL.ComputerBLL.BLLComputer_T.Computer_TField.ComputerID_int.ToString()] = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(ComputerEntity.ComputerID_int, TypeCode.Int32); // dr[HPS.BLL.ComputerBLL.BLLComputer_T.Computer_TField.Computer_nvc.ToString()] = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(ComputerEntity.Computer_nvc, TypeCode.String); // dr[HPS.BLL.ComputerBLL.BLLComputer_T.Computer_TField.IPAddress_nvc.ToString()] = Hepsa.Core.Common.PersentationController.GetEntityValue(IPTextBox.Text, TypeCode.String).ToString(); // dr[HPS.BLL.ComputerBLL.BLLComputer_T.Computer_TField.MacAddress_nvc.ToString()] = Hepsa.Core.Common.PersentationController.GetEntityValue(MacTextBox.Text, TypeCode.String).ToString(); // dr[HPS.BLL.ComputerBLL.BLLComputer_T.Computer_TField.MessageLED_nvc.ToString()] = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(ComputerEntity.MessageLED_nvc, TypeCode.String); // dr[HPS.BLL.ComputerBLL.BLLComputer_T.Computer_TField.Active_bit.ToString()] = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(ComputerEntity.Active_bit, TypeCode.Boolean); // dr[HPS.BLL.ComputerBLL.BLLComputer_T.Computer_TField.UserGroupID_int.ToString()] = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(ComputerEntity.UserGroupID_int, TypeCode.Int32); // dr["UserGroupID_intUserGroup_nvc"] = Hepsa.Core.Common.PersentationController.GetComboBoxDisplayMember(UserGroupID_intComboBox); // DataTable.Rows.Add(dr); // DataTable.AcceptChanges(); //} //this.ClearForm(this); } catch (Exception ex) { ComputerFactory.RollBackProc(); throw ex; } this.DialogResult = DialogResult.OK; }
protected override void Insert() { HPS.BLL.ComputerBLL.BLLComputer_TFactory ComputerFactory = new HPS.BLL.ComputerBLL.BLLComputer_TFactory(); try { HPS.BLL.ComputerBLL.BLLComputer_T ComputerEntity = new HPS.BLL.ComputerBLL.BLLComputer_T(); List <BLL.ComputerBLL.BLLComputer_T> ComputerList = new List <BLL.ComputerBLL.BLLComputer_T>(); ComputerList = ComputerFactory.GetAllByCondition("MacAddress_nvc=N'" + MacTextBox.Text + "'"); BLL.ComputerBLL.BLLComputer_TKeys ComputerKey = new BLL.ComputerBLL.BLLComputer_TKeys(); if (ComputerList.Find(a => a.Computer_nvc.Trim() == Hepsa.Core.Common.PersentationController.GetEntityValue(Computer_nvcComboBox.Text.Trim(), TypeCode.String).ToString() && a.Deleted_bit == false && a.MacAddress_nvc == MacTextBox.Text) == null) { ComputerEntity.Computer_nvc = Hepsa.Core.Common.PersentationController.GetEntityValue(Computer_nvcComboBox.Text, TypeCode.String).ToString(); ComputerEntity.IPAddress_nvc = Hepsa.Core.Common.PersentationController.GetEntityValue(IPTextBox.Text, TypeCode.String).ToString(); ComputerEntity.MacAddress_nvc = Hepsa.Core.Common.PersentationController.GetEntityValue(MacTextBox.Text, TypeCode.String).ToString(); ComputerEntity.MessageLED_nvc = Hepsa.Core.Common.PersentationController.GetEntityValue(MessageLED_nvcTextBox.Text, TypeCode.String).ToString(); ComputerEntity.Active_bit = Active_bitCheckBox.Checked; ComputerEntity.UserGroupID_int = (Int32?)Hepsa.Core.Common.PersentationController.GetEntityValue(UserGroupID_intComboBox.SelectedValue, TypeCode.Int32); ComputerFactory.BeginProc(); ComputerFactory.Insert(ComputerEntity); ComputerFactory.CommitProc(); } if (DataTable != null) { DataRow dr = this.DataTable.NewRow(); dr[HPS.BLL.ComputerBLL.BLLComputer_T.Computer_TField.ComputerID_int.ToString()] = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(ComputerEntity.ComputerID_int, TypeCode.Int32); dr[HPS.BLL.ComputerBLL.BLLComputer_T.Computer_TField.Computer_nvc.ToString()] = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(ComputerEntity.Computer_nvc, TypeCode.String); dr[HPS.BLL.ComputerBLL.BLLComputer_T.Computer_TField.IPAddress_nvc.ToString()] = Hepsa.Core.Common.PersentationController.GetEntityValue(IPTextBox.Text, TypeCode.String).ToString(); dr[HPS.BLL.ComputerBLL.BLLComputer_T.Computer_TField.MacAddress_nvc.ToString()] = Hepsa.Core.Common.PersentationController.GetEntityValue(MacTextBox.Text, TypeCode.String).ToString(); dr[HPS.BLL.ComputerBLL.BLLComputer_T.Computer_TField.MessageLED_nvc.ToString()] = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(ComputerEntity.MessageLED_nvc, TypeCode.String); dr[HPS.BLL.ComputerBLL.BLLComputer_T.Computer_TField.Active_bit.ToString()] = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(ComputerEntity.Active_bit, TypeCode.Boolean); dr[HPS.BLL.ComputerBLL.BLLComputer_T.Computer_TField.UserGroupID_int.ToString()] = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(ComputerEntity.UserGroupID_int, TypeCode.Int32); dr["UserGroupID_intUserGroup_nvc"] = Hepsa.Core.Common.PersentationController.GetComboBoxDisplayMember(UserGroupID_intComboBox); DataTable.Rows.Add(dr); DataTable.AcceptChanges(); } this.ClearForm(this); } catch (Exception ex) { ComputerFactory.RollBackProc(); throw ex; } }
private bool CheckComputerRegistration(HPS.BLL.UserBLL.BLLUser_T user) { if (!((new HPS.BLL.SettingsBLL.BLLSetting_TFactory()).GetBy(new BLL.SettingsBLL.BLLSetting_TKeys() { SettingID_int = 1028 }).Value_nvc == "1")) { return(true); } HPS.BLL.ComputerBLL.BLLComputer_TFactory ComputerFactory = new HPS.BLL.ComputerBLL.BLLComputer_TFactory(); //TODO: فیلد پاک شده بررسی نمیشد string ComputerCondition = "[Computer_T].[MacAddress_nvc]='" + Hepsa.Core.Common.ApplicationInfo.MacAddress + "' and [Computer_T].[Computer_nvc]='" + user.UserName_nvc + "' and [Computer_T].[active_bit]=1 and Deleted_bit=0"; List <HPS.BLL.ComputerBLL.BLLComputer_T> ComputerList = ComputerFactory.GetAllByCondition(ComputerCondition); if (ComputerList != null && ComputerList.Count > 0) { return(true); } return(false); }
protected override void Edit() { HPS.BLL.ComputerBLL.BLLComputer_TFactory ComputerFactory = new HPS.BLL.ComputerBLL.BLLComputer_TFactory(); List <BLL.ComputerBLL.BLLComputer_T> ComputerList = new List <BLL.ComputerBLL.BLLComputer_T>(); ComputerList = ComputerFactory.GetAllByCondition("MacAddress_nvc=N'" + MacTextBox.Text + "'"); BLL.ComputerBLL.BLLComputer_TKeys ComputerKey = new BLL.ComputerBLL.BLLComputer_TKeys(); foreach (BLL.ComputerBLL.BLLComputer_T item in ComputerList) { item.Deleted_bit = true; ComputerKey.ComputerID_int = item.ComputerID_int; ComputerFactory.Update(item, ComputerKey); } try { HPS.BLL.ComputerBLL.BLLComputer_T ComputerEntity = new HPS.BLL.ComputerBLL.BLLComputer_T(); foreach (Janus.Windows.GridEX.GridEXRow item in UserNameGridView.GetCheckedRows()) { ComputerEntity.ComputerID_int = null; ComputerEntity.Computer_nvc = item.Cells["username_nvc"].Value.ToString(); ComputerEntity.IPAddress_nvc = Hepsa.Core.Common.PersentationController.GetEntityValue(IPTextBox.Text, TypeCode.String).ToString(); ComputerEntity.MacAddress_nvc = Hepsa.Core.Common.PersentationController.GetEntityValue(MacTextBox.Text, TypeCode.String).ToString(); ComputerEntity.MessageLED_nvc = Hepsa.Core.Common.PersentationController.GetEntityValue(MessageLED_nvcTextBox.Text, TypeCode.String).ToString(); ComputerEntity.Active_bit = Active_bitCheckBox.Checked; ComputerEntity.UserGroupID_int = (Int32)item.Cells["UserGroupID_int"].Value; ComputerFactory.BeginProc(); ComputerFactory.Insert(ComputerEntity); ComputerFactory.CommitProc(); } } catch (Exception ex) { ComputerFactory.RollBackProc(); throw ex; } }