Esempio n. 1
0
 private void RaiseItemSelectedEventHander(DIC_STATE item)
 {
     if (this.ItemSelected != null)
     {
         this.ItemSelected(this, item);
     }
 }
Esempio n. 2
0
 public void RaiseUpdatedEventHander(DIC_STATE Item)
 {
     if (this.Updated != null)
     {
         this.Updated(this, Item);
     }
 }
Esempio n. 3
0
 private void RaiseSuccessEventHander(DIC_STATE item)
 {
     if (this.Success != null)
     {
         this.Success(this, item);
     }
 }
Esempio n. 4
0
        protected override void Add()
        {
            base.Add();
            DIC_STATE dICSTATE = new DIC_STATE();

            this.txtID.Text = dICSTATE.NewID();
            this.txtNAME.Focus();
        }
Esempio n. 5
0
        public xfmStateAdd(Actions Action)
        {
            this.InitializeComponent();
            this.Init();
            this.ucAdd.Status = Action;
            DIC_STATE dICSTATE = new DIC_STATE();

            this.ucAdd.SetData(dICSTATE.NewID());
            this.Text = "Thêm ";
        }
Esempio n. 6
0
        public override void Delete()
        {
            string str;
            object rowCellValue;
            bool   flag = false;

            int[] selectedRows = this.gbList.GetSelectedRows();
            if (XtraMessageBox.Show("Bạn có muốn xóa không?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.No)
            {
                base.SetWaitDialogCaption("Đang xóa...");
                DIC_STATE dICSTATE = new DIC_STATE();
                for (int i = (int)selectedRows.Length; i > 0; i--)
                {
                    flag         = true;
                    rowCellValue = this.gbList.GetRowCellValue(selectedRows[i - 1], "StateCode");
                    if (rowCellValue != null)
                    {
                        //  SYS_LOG.Insert("Danh Mục Công Đoạn", "Xoá", rowCellValue.ToString());
                        str = dICSTATE.Delete(rowCellValue.ToString());
                        if (str == "OK")
                        {
                            this.gbList.DeleteRow(selectedRows[i - 1]);
                        }
                        else if (str != "OK")
                        {
                            MessageBox.Show(string.Concat("Thông tin không được xóa\r\n", str), "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                        }
                    }
                }
                this.DoHide();
                if (!flag)
                {
                    if (dICSTATE.GetList().Rows.Count != 0)
                    {
                        rowCellValue = this.gbList.GetFocusedRowCellValue("StateCode");
                        if (rowCellValue != null)
                        {
                            // SYS_LOG.Insert("Danh Mục Công Đoạn", "Xoá", rowCellValue.ToString());
                            base.SetWaitDialogCaption("Đang xóa...");
                            str = dICSTATE.Delete(rowCellValue.ToString());
                            if (str == "OK")
                            {
                                this.gbList.DeleteRow(this.gbList.FocusedRowHandle);
                            }
                            else if (str != "OK")
                            {
                                MessageBox.Show(string.Concat("Thông tin không được xóa\r\n", str), "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                            }
                            this.DoHide();
                        }
                    }
                }
            }
        }
Esempio n. 7
0
        public override void ReLoad()
        {
            base.SetWaitDialogCaption("Đang nạp dữ liệu...");
            DIC_STATE dICSTATE = new DIC_STATE();

            this.gcList.DataSource = dICSTATE.GetList();
            base.SetWaitDialogCaption("Đang nạp cấu hình...");
            this.gbList.ClearColumnsFilter();
            base.SetWaitDialogCaption("Đã xong...");
            this.DoHide();
        }
Esempio n. 8
0
        private DIC_STATE InitClass()
        {
            DIC_STATE dICSTATE = new DIC_STATE()
            {
                StateCode   = this.txtID.Text,
                StateName   = this.txtNAME.Text,
                Price       = decimal.Parse(this.calPrice.EditValue.ToString()),
                Unit        = this.cboUnit.Text,
                Description = this.txtDescription.Text
            };

            return(dICSTATE);
        }
Esempio n. 9
0
 public void SetData(DIC_STATE item)
 {
     this.txtID.Text = item.StateCode;
     // SYS_LOG.Insert("Danh Mục Công Đoạn", "Xem", this.txtID.Text);
     if (this.m_Status == Actions.Update)
     {
         this.txtID.Properties.ReadOnly = true;
     }
     this.txtNAME.Text        = item.StateName;
     this.calPrice.EditValue  = item.Price;
     this.cboUnit.Text        = item.Unit;
     this.txtDescription.Text = item.Description;
 }
Esempio n. 10
0
        protected override string uc_Delete()
        {
            DIC_STATE dICSTATE = new DIC_STATE()
            {
                StateCode = this.txtID.Text
            };
            string str = dICSTATE.Delete();

            if (str == "OK")
            {
                this.RaiseSuccessEventHander(dICSTATE);
            }
            return(str);
        }
Esempio n. 11
0
 public xfmStateAdd(Actions Action, DIC_STATE Item)
 {
     this.InitializeComponent();
     this.Init();
     this.ucAdd.Status = Action;
     if (Action == Actions.Update)
     {
         this.ucAdd.SetData(Item);
         this.Text = "Cập Nhật ";;
     }
     else if (Action == Actions.Delete)
     {
         this.ucAdd.SetData(Item.StateCode);
     }
 }
Esempio n. 12
0
 private void ucAdd_Success(object sender, DIC_STATE Item)
 {
     if (this.ucAdd.Status == Actions.Add)
     {
         this.RaiseAddedEventHander(Item);
     }
     else if (this.ucAdd.Status == Actions.Update)
     {
         this.RaiseUpdatedEventHander(Item);
     }
     if (this.ucAdd.IsClose == CloseOrNew.Close)
     {
         base.Close();
     }
     this.ucAdd.Clear();
 }
Esempio n. 13
0
        protected override void txtID_KeyDown(object sender, KeyEventArgs e)
        {
            TextEdit textEdit = (TextEdit)sender;

            if (e.KeyCode == Keys.Return | e.KeyCode == Keys.Tab)
            {
                DIC_STATE dICSTATE = new DIC_STATE();
                if (this.m_Status == Actions.Add)
                {
                    if (dICSTATE.Exist(textEdit.Text))
                    {
                        this.Err.SetError(textEdit, "Mã đã tồn tại.");
                        textEdit.Focus();
                    }
                }
            }
        }
Esempio n. 14
0
        private void Init()
        {
            MyRule.Check("bbiProduct");
            this.ucToolBar.bbiPrint.Visibility  = MyRule.Printed;
            this.ucToolBar.bbiExport.Visibility = MyRule.Exported;
            this.ucToolBar.bbiAdd.Visibility    = MyRule.Added;
            this.ucToolBar.bbiDelete.Visibility = MyRule.Deleted;
            this.ucToolBar.bbiEdit.Visibility   = MyRule.Edited;
            base.RibbonBar.Add.Visibility       = MyRule.Added;
            base.RibbonBar.Change.Visibility    = MyRule.Edited;
            base.RibbonBar.Delete.Visibility    = MyRule.Deleted;
            base.RibbonBar.Print.Visibility     = MyRule.Printed;
            base.RibbonBar.Export.Visibility    = MyRule.Exported;
            base.RibbonBar.Import.Visibility    = MyRule.Imported;
            DIC_STATE dICSTATE = new DIC_STATE();

            this.gcList.DataSource = dICSTATE.GetList();
        }
Esempio n. 15
0
        protected override string uc_Update()
        {
            //  SYS_LOG.Insert("Danh Mục Công Đoạn", "Cập Nhật", this.txtID.Text);
            base.SetWaitDialogCaption("Đang cập nhật dữ liệu...");
            DIC_STATE dICSTATE = this.InitClass();
            string    str      = dICSTATE.Update();

            if (str == "OK")
            {
                this.RaiseSuccessEventHander(dICSTATE);
            }
            if (str != "OK")
            {
                XtraMessageBox.Show(str, "Cảnh Báo", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            this.DoHide();
            return(str);
        }
Esempio n. 16
0
        protected override string uc_Save()
        {
            //   SYS_LOG.Insert("Danh Mục Công Đoạn", "Thêm", this.txtID.Text);
            base.SetWaitDialogCaption("Đang lưu dữ liệu...");
            Cursor.Current = Cursors.WaitCursor;
            DIC_STATE dICSTATE = this.InitClass();
            string    str      = dICSTATE.Insert();

            if (str == "OK")
            {
                this.RaiseSuccessEventHander(dICSTATE);
            }
            Cursor.Current = Cursors.Default;
            this.DoHide();
            if (str != "OK")
            {
                XtraMessageBox.Show(str, "Cảnh Báo", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            return(str);
        }
Esempio n. 17
0
 public override void SetSearch(CHBK2014_N9.Common.Class.RowClickEventArgs e)
 {
     if (this._search)
     {
         DIC_STATE dICSTATE     = new DIC_STATE();
         object    rowCellValue = this.gbList.GetRowCellValue(this.MRowClickEventArgs.RowIndex, "StateCode");
         if (rowCellValue != null)
         {
             base.SetWaitDialogCaption("Đang kiểm tra dữ liệu....");
             if (!(dICSTATE.Get(rowCellValue.ToString()) != "OK"))
             {
                 this.DoHide();
                 this.RaiseItemSelectedEventHander(dICSTATE);
             }
             else
             {
                 this.DoHide();
                 XtraMessageBox.Show("Dữ liệu không tồn tại", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
             }
         }
     }
 }
Esempio n. 18
0
        public override void Change()
        {
            DIC_STATE dICSTATE            = new DIC_STATE();
            object    focusedRowCellValue = this.gbList.GetFocusedRowCellValue("StateCode");

            if (focusedRowCellValue != null)
            {
                base.SetWaitDialogCaption("Đang kiểm tra dữ liệu....");
                if (!(dICSTATE.Get(focusedRowCellValue.ToString()) != "OK"))
                {
                    this.DoHide();
                    xfmStateAdd _xfmStateAdd = new xfmStateAdd(Actions.Update, dICSTATE);
                    _xfmStateAdd.Updated += new xfmStateAdd.UpdatedEventHander(this.frm_Updated);
                    _xfmStateAdd.Added   += new xfmStateAdd.AddedEventHander(this.frm_Added);
                    _xfmStateAdd.ShowDialog();
                }
                else
                {
                    this.DoHide();
                    XtraMessageBox.Show("Dữ liệu không tồn tại", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }
        }
Esempio n. 19
0
 private void frm_Updated(object sender, DIC_STATE Item)
 {
     this.ReLoad();
 }
Esempio n. 20
0
        private static int ChangeDeviceState(string hardwareId, DIC_STATE stateChange)
        {
            IntPtr deviceInfoSet = IntPtr.Zero;
            int    error         = 0;

            try
            {
                deviceInfoSet = SetupDiGetClassDevsEx(
                    IntPtr.Zero,
                    IntPtr.Zero,
                    IntPtr.Zero,
                    DIGCF_ALLCLASSES,
                    IntPtr.Zero,
                    IntPtr.Zero,
                    IntPtr.Zero);

                SP_DEVINFO_DATA deviceInfoData = new SP_DEVINFO_DATA();

                deviceInfoData.CbSize = (uint)Marshal.SizeOf(deviceInfoData);
                uint index = 0;
                while (SetupDiEnumDeviceInfo(
                           deviceInfoSet,
                           index,
                           ref deviceInfoData))
                {
                    index++;

                    uint requiredSize = 0;
                    SetupDiGetDeviceRegistryProperty(
                        deviceInfoSet,
                        ref deviceInfoData,
                        SPDRP_HARDWAREID,
                        IntPtr.Zero,
                        IntPtr.Zero,
                        0,
                        ref requiredSize);

                    if (requiredSize == 0)
                    {
                        continue;
                    }

                    IntPtr pPropertyBuffer = Marshal.AllocHGlobal((int)requiredSize);

                    if (!SetupDiGetDeviceRegistryProperty(
                            deviceInfoSet,
                            ref deviceInfoData,
                            SPDRP_HARDWAREID,
                            IntPtr.Zero,
                            pPropertyBuffer,
                            requiredSize,
                            IntPtr.Zero))
                    {
                        continue;
                    }

                    string hwId = Marshal.PtrToStringAuto(pPropertyBuffer);
                    Marshal.FreeHGlobal(pPropertyBuffer);

                    if (hwId.Equals(hardwareId))
                    {
                        SP_PROPCHANGE_PARAMS propChangeParams = new SP_PROPCHANGE_PARAMS();
                        propChangeParams.ClassInstallHeader.CbSize          = (uint)Marshal.SizeOf(propChangeParams.ClassInstallHeader);
                        propChangeParams.ClassInstallHeader.InstallFunction = DI_FUNCTION.DIF_PROPERTYCHANGE;
                        propChangeParams.Scope       = DI_REMOVEDEVICE_GLOBAL;
                        propChangeParams.StateChange = stateChange;
                        if (!SetupDiSetClassInstallParams(
                                deviceInfoSet,
                                ref deviceInfoData,
                                ref propChangeParams,
                                (uint)Marshal.SizeOf(propChangeParams)))
                        {
                            error = Marshal.GetLastWin32Error();
                        }
                        if (!SetupDiChangeState(
                                deviceInfoSet,
                                ref deviceInfoData))
                        {
                            error = Marshal.GetLastWin32Error();
                        }
                    }
                }
            }
            finally
            {
                if (deviceInfoSet != IntPtr.Zero)
                {
                    SetupDiDestroyDeviceInfoList(deviceInfoSet);
                }
            }

            return(error);
        }