private void gridControlUsers_EmbeddedNavigator_ButtonClick(object sender, DevExpress.XtraEditors.NavigatorButtonClickEventArgs e)
        {
            try
            {
                if (e.Button.ButtonType == DevExpress.XtraEditors.NavigatorButtonType.Remove)
                {
                    var dataRow  = this.gridViewUsers.GetDataRow(this.gridViewUsers.FocusedRowHandle) as DataRow;
                    var userName = dataRow["UserName"].ToString();

                    if (!string.IsNullOrEmpty(userName))
                    {
                        if ((MessageBox.Show(string.Format(Properties.Resources.MessageDisable_Confirmation, userName),
                                             Properties.Resources.Title_ConfirmAction,
                                             MessageBoxButtons.YesNo,
                                             MessageBoxIcon.Question) == DialogResult.Yes))
                        {
                            e.Handled = base.ServiceClient.DisableUser(userName);
                        }
                    }
                    else
                    {
                        e.Handled = false;
                    }

                    this.Refresh();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        private void gridControlRatings_EmbeddedNavigator_ButtonClick(object sender, DevExpress.XtraEditors.NavigatorButtonClickEventArgs e)
        {
            try
            {
                if (e.Button.ButtonType == DevExpress.XtraEditors.NavigatorButtonType.Remove)
                {
                    var itemToDelete = this.gridViewRatings.GetRow(this.gridViewRatings.FocusedRowHandle) as RatingDto;

                    if (itemToDelete != null)
                    {
                        if ((MessageBox.Show(string.Format(Properties.Resources.MessageDelete_Confirmation, itemToDelete.Name),
                                             Properties.Resources.Title_ConfirmAction,
                                             MessageBoxButtons.YesNo,
                                             MessageBoxIcon.Question) == DialogResult.Yes))
                        {
                            e.Handled = base.ServiceClient.DeleteRating(itemToDelete.Id);
                        }
                    }
                    else
                    {
                        throw new Exception("The item does not exist !");
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, Properties.Resources.Error_Title, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemple #3
0
        //public override bool PerformSaveChanges()
        //{
        // GoobizFrame.Windows.Public.OrderHashtable hashtableControls = new  GoobizFrame.Windows.Public.OrderHashtable();
        ////hashtableControls.Add(gridView1.Columns["Dongia"], "");
        //hashtableControls.Add(gridView1.Columns["Id_Menu"], "");
        //hashtableControls.Add(gridView1.Columns["Id_Hanghoa_Ban"], "");

        //if (! GoobizFrame.Windows.MdiUtils.Validator.CheckNullGrid(hashtableControls, gridView1))
        //    return false;

        //try
        //{
        //    dgbar_Dm_Menu_Hanghoa_Ban.EmbeddedNavigator.Buttons.EndEdit.DoClick();
        //    //ds_Menu_Hanghoa_Ban.Tables[0].Columns["Id_Menu"].Unique = true;
        //    //ds_Menu_Hanghoa_Ban.Tables[0].Columns["Id_Hanghoa_Ban"].Unique = true;
        //    objMasterService.Update_Bar_Dm_Menu_Hanghoa_Ban_Collection(this.ds_Menu_Hanghoa_Ban);
        //}
        //catch (Exception ex)
        //{

        //    if (ex.ToString().IndexOf("Unique") != -1 && ex.ToString().IndexOf("Id_Menu") != -1)
        //    {
        //        // GoobizFrame.Windows.Forms.UserMessage.Show("SYS_ALREADY_EXIST", new string[] { lblId_Menu.Text, lblId_Menu.Text });
        //        return false;
        //    }
        //    else if (ex.ToString().IndexOf("Unique") != -1 && ex.ToString().IndexOf("Id_Hanghoa_Ban") != -1)
        //    {
        //        // GoobizFrame.Windows.Forms.UserMessage.Show("SYS_ALREADY_EXIST", new string[] { lblId_Hanghoa_Ban.Text, lblId_Hanghoa_Ban.Text });
        //        return false;
        //    }
        //    MessageBox.Show(ex.ToString());
        //}
        //this.DisplayInfo();
        //    return true;
        //}


        //private void gridLookUpEdit_Menu_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
        //{
        //    if (e.Button.Kind == DevExpress.XtraEditors.Controls.ButtonPredefines.Ellipsis)
        //    {
        //        Frmbar_Dm_Menu_Add objFrmbar_Dm_Menu_Add = new Frmbar_Dm_Menu_Add();
        //        objFrmbar_Dm_Menu_Add.Text = "Menu";
        //         GoobizFrame.Windows.MdiUtils.ThemeSettings.SetDialogShow(objFrmbar_Dm_Menu_Add);
        //        objFrmbar_Dm_Menu_Add.ShowDialog();
        //        objFrmbar_Dm_Menu_Add.Text = gridView1.Columns["Id_Menu"].Caption;
        //        if (objFrmbar_Dm_Menu_Add.SelectedBar_Dm_Menu != null
        //            && "" + objFrmbar_Dm_Menu_Add.SelectedBar_Dm_Menu.Id_Menu != "")
        //        {
        //            gridLookUpEdit_Menu.DataSource = objFrmbar_Dm_Menu_Add.Data.Tables[0];
        //            //lookUpEdit_Menu.Properties.DataSource = objFrmbar_Dm_Menu_Add.Data.Tables[0];
        //            gridView1.SetFocusedRowCellValue(gridView1.Columns["Id_Menu"], objFrmbar_Dm_Menu_Add.SelectedBar_Dm_Menu.Id_Menu);
        //        }
        //    }
        //}

        //private void btnMenu_Click(object sender, EventArgs e)
        //{

        //    if (frmbar_Dm_Menu_Add.IsDisposed || frmbar_Dm_Menu_Add == null)
        //        frmbar_Dm_Menu_Add = new Frmbar_Dm_Menu_Add();
        //     GoobizFrame.Windows.MdiUtils.ThemeSettings.SetDialogShow(frmbar_Dm_Menu_Add);
        //     GoobizFrame.Windows.PlugIn.RightHelpers.CheckUserRightAction(frmbar_Dm_Menu_Add);


        //    frmbar_Dm_Menu_Add.Show();
        //}

        #endregion

        private void dgbar_Dm_Menu_EmbeddedNavigator_ButtonClick(object sender, DevExpress.XtraEditors.NavigatorButtonClickEventArgs e)
        {
            if (e.Button.ButtonType == DevExpress.XtraEditors.NavigatorButtonType.Remove)
            {
                if (gridView1.GetFocusedRowCellValue("Id_Menu_Hanghoa_Ban").ToString() != "")
                {
                    if (Convert.ToInt32(objMasterService.GetExistReferences("Bar_Dm_Menu_Hanghoa_Ban", "Id_Menu_Hanghoa_Ban", this.gridView1.GetFocusedRowCellValue("Id_Menu_Hanghoa_Ban"))) > 0)
                    {
                        GoobizFrame.Windows.Forms.UserMessage.Show("Msg00015", new string[] { this.Text.ToLower() });
                        e.Handled = true;
                    }
                }
                if (this.FormState == GoobizFrame.Windows.Forms.FormState.View)
                {
                    this.FormState = GoobizFrame.Windows.Forms.FormState.Edit;
                }
                changeStatusButtonMenu(true);
            }
            if (e.Button.ButtonType == DevExpress.XtraEditors.NavigatorButtonType.Append)
            {
                if (this.FormState == GoobizFrame.Windows.Forms.FormState.View)
                {
                    this.FormState = GoobizFrame.Windows.Forms.FormState.Edit;
                }
                gridView1.OptionsBehavior.Editable = true;
                changeStatusButtonMenu(true);
            }
        }
Exemple #4
0
 private void gridControl1_EmbeddedNavigator_ButtonClick(object sender, DevExpress.XtraEditors.NavigatorButtonClickEventArgs e)
 {
     if (e.Button.ButtonType == DevExpress.XtraEditors.NavigatorButtonType.EndEdit)
     {
         ColumnView view = (ColumnView)gridControl1.FocusedView;
         view.CloseEditor();
         if (view.UpdateCurrentRow())
         {
             try {
                 dc.SubmitChanges(ConflictMode.FailOnFirstConflict);
             }
             catch (ChangeConflictException ex) {
                 MessageBox.Show(ex.Message);
                 foreach (ObjectChangeConflict occ in dc.ChangeConflicts)
                 {
                     occ.Resolve(RefreshMode.OverwriteCurrentValues);
                 }
                 //view.RefreshData();
             }
             catch (Exception ex) {
                 MessageBox.Show(ex.Message);
                 BindGrid();
             }
         }
         e.Handled = true;
     }
 }
Exemple #5
0
 private void gc_Detail_EmbeddedNavigator_ButtonClick(object sender, DevExpress.XtraEditors.NavigatorButtonClickEventArgs e)
 {
     if (e.Button.ButtonType == DevExpress.XtraEditors.NavigatorButtonType.Remove)
     {
         e.Handled = Msg.AskQuestion("是否确定要删除选中行?") == false;
     }
 }
 private void dgacc_Dm_Nganhang_EmbeddedNavigator_ButtonClick(object sender, DevExpress.XtraEditors.NavigatorButtonClickEventArgs e)
 {
     if (e.Button.ButtonType == DevExpress.XtraEditors.NavigatorButtonType.Append)
     {
         this.gridView1.FocusedColumn = gridView1.Columns["Ma_Nganhang"];
         this.addnewrow_clicked       = true;
     }
 }
Exemple #7
0
 private void gcSampleControl_EmbeddedNavigator_ButtonClick(object sender, DevExpress.XtraEditors.NavigatorButtonClickEventArgs e)
 {
     if (e.Button.ButtonType == DevExpress.XtraEditors.NavigatorButtonType.Append)
     {
         e.Handled = true;
         MessageBox.Show("");
     }
 }
 private void dgacc_Dm_Tiente_EmbeddedNavigator_ButtonClick(object sender, DevExpress.XtraEditors.NavigatorButtonClickEventArgs e)
 {
     if (e.Button.ButtonType == DevExpress.XtraEditors.NavigatorButtonType.Remove)
     {
         if (Convert.ToInt32(objMasterService.GetExistReferences("Ware_Dm_Tiente", "Id_Tiente", this.gridView1.GetFocusedRowCellValue("Id_Tiente"))) > 0)
         {
             GoobizFrame.Windows.Forms.UserMessage.Show("Msg00015", new string[] { this.Text.ToLower() });
             e.Handled = true;
         }
     }
 }
Exemple #9
0
 private void dgbar_Table_Cash_EmbeddedNavigator_ButtonClick(object sender, DevExpress.XtraEditors.NavigatorButtonClickEventArgs e)
 {
     if (e.Button.ButtonType == DevExpress.XtraEditors.NavigatorButtonType.Remove)
     {
         if ("" + gridView2.GetFocusedRowCellValue(gridView2.Columns["Served"]) != "")
         {
             GoobizFrame.Windows.Forms.MessageDialog.Show("Món này đã phục vụ nên không thể xóa", "Thông báo");
             e.Handled = true; //cancel
         }
     }
 }
 private void gridControl1_EmbeddedNavigator_ButtonClick(object sender, DevExpress.XtraEditors.NavigatorButtonClickEventArgs e)
 {
     if ("copy".Equals(e.Button.Tag))
     {
         if (gridControl1.FocusedView != null)
         {
             gridControl1.FocusedView.CopyToClipboard();
             MessageBox.Show("Selected data has been copied to the Clipboard");
             e.Handled = true;
         }
     }
 }
Exemple #11
0
        private void gridControl1_EmbeddedNavigator_ButtonClick(object sender, DevExpress.XtraEditors.NavigatorButtonClickEventArgs e)
        {
            if (gridView1.FocusedRowHandle < 0)
            {
                return;
            }
            if (e.Button.ButtonType == DevExpress.XtraEditors.NavigatorButtonType.Custom && e.Button.Tag != null && e.Button.Tag.ToString() == "Del")
            {
                gridView1.DeleteRow(gridView1.FocusedRowHandle);

                this.setEnable(EventKind.DataChanged);
            }
        }
 private void gridControl1_EmbeddedNavigator_ButtonClick(object sender, DevExpress.XtraEditors.NavigatorButtonClickEventArgs e)
 {
     if (e.Button.ButtonType == DevExpress.XtraEditors.NavigatorButtonType.Custom)
     {
         ShowEditForm();
     }
     else if (e.Button.ButtonType == DevExpress.XtraEditors.NavigatorButtonType.Append)
     {
         suppliersBindingSource.AddNew();
         ShowEditForm();
         e.Handled = true;
     }
 }
Exemple #13
0
 private void dgrex_Dm_Bophan_EmbeddedNavigator_ButtonClick(object sender, DevExpress.XtraEditors.NavigatorButtonClickEventArgs e)
 {
     if (e.Button.ButtonType == DevExpress.XtraEditors.NavigatorButtonType.Remove)
     {
         if ("" + this.bandedGridView1.GetFocusedRowCellValue("Id_Bophan") != "")
         {
             if (Convert.ToInt32(objMasterService.GetExistReferences("Rex_Dm_Bophan", "Id_Bophan", this.bandedGridView1.GetFocusedRowCellValue("Id_Bophan"))) > 0)
             {
                 GoobizFrame.Windows.Forms.UserMessage.Show("SYS_DATA_INUSE", new string[] { this.Text.ToLower() });
                 e.Handled = true;
             }
         }
     }
 }
Exemple #14
0
 void EmbeddedNavigator_ButtonClick(object sender, DevExpress.XtraEditors.NavigatorButtonClickEventArgs e)
 {
     if (e.Button.Tag.ToString() == "增加")
     {
         增加ToolStripMenuItem_Click(sender, new EventArgs());
     }
     if (e.Button.Tag.ToString() == "删除")
     {
         除ToolStripMenuItem_Click(sender, new EventArgs());
     }
     if (e.Button.Tag.ToString() == "查看")
     {
         查看ToolStripMenuItem_Click(sender, new EventArgs());
     }
 }
 private void dgbar_Dm_Menu_EmbeddedNavigator_ButtonClick(object sender, DevExpress.XtraEditors.NavigatorButtonClickEventArgs e)
 {
     if (e.Button.ButtonType == DevExpress.XtraEditors.NavigatorButtonType.Remove)
     {
         if (MessageBox.Show("Bạn có chắc xóa menu và các món ăn trong menu này?", "Confirm Dialog", MessageBoxButtons.YesNo) == DialogResult.Yes)
         {
             e.Handled = true;
             gridView1.DeleteRow(gridView1.FocusedRowHandle);
         }
         //if (Convert.ToInt32(objMasterService.GetExistReferences("Bar_Dm_Menu", "Id_Menu", this.gridView1.GetFocusedRowCellValue("Id_Menu"))) > 0)
         //{
         //     GoobizFrame.Windows.Forms.UserMessage.Show("Msg00015", new string[] { this.Text.ToLower() });
         //    e.Handled = true;
         //}
     }
 }
Exemple #16
0
        private void gridControl_EmbeddedNavigator_ButtonClick(object sender, DevExpress.XtraEditors.NavigatorButtonClickEventArgs e)
        {
            if (e.Button.ButtonType == DevExpress.XtraEditors.NavigatorButtonType.Remove)
            {
                string DeleteFromTableName = "QT_Functions";

                int    r = gridView1.GetSelectedRows()[0];
                string SelectedDeletingValue = gridView1.GetRowCellValue(r, "FunctionCode").ToString();

                Forms.formReplaceDeleted rd = new Forms.formReplaceDeleted(SetupTypes.Function, SelectedDeletingValue);
                if (rd.ShowDialog() == DialogResult.OK)
                {
                    string replacementString = DeleteFromTableName + "," + SelectedDeletingValue + "," + rd.SelectedReplacementValue;
                    ReplacementList.Add(replacementString);
                }
            }
        }
Exemple #17
0
 private void dgbar_Dm_Table_EmbeddedNavigator_ButtonClick(object sender, DevExpress.XtraEditors.NavigatorButtonClickEventArgs e)
 {
     if (e.Button.ButtonType == DevExpress.XtraEditors.NavigatorButtonType.Remove)
     {
         if ("" + this.gridView1.GetFocusedRowCellValue("Id_Table") != "")
         {
             if (Convert.ToInt32(objMasterService.GetExistReferences("Bar_Dm_Table", "Id_Table", this.gridView1.GetFocusedRowCellValue("Id_Table"))) > 0)
             {
                 itvs.Windows.Forms.UserMessage.Show("Msg00015", new string[] { this.Text.ToLower() });
                 e.Handled = true;
             }
         }
     }
     if (e.Button.ButtonType == DevExpress.XtraEditors.NavigatorButtonType.Append)
     {
         gridView1.OptionsBehavior.Editable = true;
     }
 }
Exemple #18
0
 private void xtraHNavigator1_ButtonClick(object sender, DevExpress.XtraEditors.NavigatorButtonClickEventArgs e)
 {
     if (e.Button.ButtonType == DevExpress.XtraEditors.NavigatorButtonType.Remove)
     {
         if (this.gvDm_Khahhang.GetFocusedDataRow().RowState != DataRowState.Added)
         {
             try
             {
                 objMasterService.CheckDelete_Ware_Dm_Khachhang(gvDm_Khahhang.GetFocusedRowCellValue("Id_Khachhang"));
             }
             catch (Exception ex)
             {
                 ex.ToString();
                 GoobizFrame.Windows.Forms.UserMessage.Show("Msg00015", new string[] { this.Text.ToLower() });
                 e.Handled = true;
             }
         }
     }
 }
Exemple #19
0
 private void xtraHNavigator1_ButtonClick(object sender, DevExpress.XtraEditors.NavigatorButtonClickEventArgs e)
 {
     if (e.Button.ButtonType == DevExpress.XtraEditors.NavigatorButtonType.Remove)
     {
         if ("" + gridView1.GetFocusedRowCellValue("Id_Hanghoa_Ban") != "")
         {
             try
             {
                 TruthPos.WebReferences.MasterService.Ware_Dm_Hanghoa_Ban objWare_Dm_Hanghoa_Ban = new TruthPos.WebReferences.MasterService.Ware_Dm_Hanghoa_Ban();
                 objWare_Dm_Hanghoa_Ban.Id_Hanghoa_Ban = gridView1.GetFocusedRowCellValue("Id_Hanghoa_Ban");
                 objMasterService.Delete_Ware_Dm_Hanghoa_Ban(objWare_Dm_Hanghoa_Ban);
             }
             catch (Exception ex)
             {
                 itvs.Windows.Forms.UserMessage.Show("Msg00015", new string[] { this.Text.ToLower() });
                 e.Handled = true;
             }
         }
     }
 }
Exemple #20
0
 private void gridControl2_EmbeddedNavigator_ButtonClick(object sender, DevExpress.XtraEditors.NavigatorButtonClickEventArgs e)
 {
     if (e.Button.Tag.ToString() == "1")
     {
         xtraTabControl1.Focus();
         gridView2.AddNewRow();
         TypeUid = Guid.NewGuid().ToString();
         gridView2.SetRowCellValue(gridView2.FocusedRowHandle, "UID", TypeUid);
         gridView2.UpdateCurrentRow();
     }
     if (e.Button.Tag.ToString() == "2")
     {
         if (gridView2.RowCount < 1)
         {
             return;
         }
         DataRow row = gridView2.GetDataRow(gridView2.FocusedRowHandle);
         Services.BaseService.Delete <UsepropertyType>(Itop.Common.DataConverter.RowToObject <UsepropertyType>(row));
         gridView2.DeleteRow(gridView2.FocusedRowHandle);
     }
 }
Exemple #21
0
        private void gridControl1_EmbeddedNavigator_ButtonClick(object sender, DevExpress.XtraEditors.NavigatorButtonClickEventArgs e)
        {
            if (e.Button.ButtonType == DevExpress.XtraEditors.NavigatorButtonType.EndEdit)
            {
                if (MessageBox.Show("Do you want to save the changes?", "Save changes?", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    if (gridView1.IsEditing)
                    {
                        gridView1.CloseEditor();
                    }

                    if (gridView1.FocusedRowModified)
                    {
                        gridView1.UpdateCurrentRow();
                    }
                }
                else
                {
                    e.Handled = true;
                }
            }
        }
Exemple #22
0
        private void gridControlBrand_EmbeddedNavigator_ButtonClick(object sender, DevExpress.XtraEditors.NavigatorButtonClickEventArgs e)
        {
            try
            {
                if (e.Button.ButtonType == DevExpress.XtraEditors.NavigatorButtonType.Remove)
                {
                    var brand = this.gridViewBrand.GetRow(this.gridViewBrand.FocusedRowHandle) as BrandDto;

                    if (brand != null)
                    {
                        if (MessageBox.Show(string.Format(Properties.Resources.MessageDelete_Confirmation, brand.Name),
                                            Properties.Resources.Title_ConfirmAction, MessageBoxButtons.YesNo,
                                            MessageBoxIcon.Question) == DialogResult.Yes)
                        {
                            var success = base.ServiceClient.DeleteBrand(brand);

                            if (!success)
                            {
                                MessageBox.Show("Unable to delete brand", Properties.Resources.Error_Title, MessageBoxButtons.OK, MessageBoxIcon.Error);
                            }
                            else
                            {
                                MessageBox.Show(Properties.Resources.Message_DeleteSuccessfull, string.Empty, MessageBoxButtons.OK, MessageBoxIcon.Information);
                            }

                            e.Handled = success;
                        }
                    }
                }
                else
                {
                    throw new Exception("The item does not exist !");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, Properties.Resources.Error_Title, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        /// <summary>
        /// 全局变量
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void dnStoreOrder_ButtonClick(object sender, DevExpress.XtraEditors.NavigatorButtonClickEventArgs e)
        {
            switch (e.Button.Tag.ToString())
            {
            case "0":    //第一页
                _dataPagingModelSend.StartSize        = 1;
                dnStoreOrder.CustomButtons[0].Enabled = false;
                dnStoreOrder.CustomButtons[1].Enabled = false;
                dnStoreOrder.CustomButtons[2].Enabled = _dataPagingModelGet.TotalCount > _dataPagingModelSend.PageCount;
                dnStoreOrder.CustomButtons[3].Enabled = _dataPagingModelGet.TotalCount > _dataPagingModelSend.PageCount;
                break;

            case "1":     //上一页
                _dataPagingModelSend.StartSize        = _dataPagingModelSend.StartSize - _dataPagingModelSend.PageCount;
                dnStoreOrder.CustomButtons[0].Enabled = _dataPagingModelSend.StartSize > 1;
                dnStoreOrder.CustomButtons[1].Enabled = _dataPagingModelSend.StartSize > 1;
                dnStoreOrder.CustomButtons[2].Enabled = true;
                dnStoreOrder.CustomButtons[3].Enabled = true;
                break;

            case "2":     //下一页
                _dataPagingModelSend.StartSize        = _dataPagingModelSend.StartSize + _dataPagingModelSend.PageCount;
                dnStoreOrder.CustomButtons[0].Enabled = true;
                dnStoreOrder.CustomButtons[1].Enabled = true;
                dnStoreOrder.CustomButtons[2].Enabled = _dataPagingModelGet.TotalCount - _dataPagingModelSend.StartSize > _dataPagingModelSend.PageCount;
                dnStoreOrder.CustomButtons[3].Enabled = _dataPagingModelGet.TotalCount - _dataPagingModelSend.StartSize > _dataPagingModelSend.PageCount;
                break;

            case "3":     //最后一页
                _dataPagingModelSend.StartSize        = _dataPagingModelGet.TotalCount - (_dataPagingModelGet.TotalCount % _dataPagingModelSend.PageCount <= 1 ? _dataPagingModelSend.PageCount : _dataPagingModelGet.TotalCount % _dataPagingModelSend.PageCount) + 1;
                dnStoreOrder.CustomButtons[0].Enabled = _dataPagingModelGet.TotalCount > _dataPagingModelSend.PageCount;
                dnStoreOrder.CustomButtons[1].Enabled = _dataPagingModelGet.TotalCount > _dataPagingModelSend.PageCount;
                dnStoreOrder.CustomButtons[2].Enabled = false;
                dnStoreOrder.CustomButtons[3].Enabled = false;
                break;
            }
            BindDgvData();
        }
        private void gridControl_EmbeddedNavigator_ButtonClick(object sender, DevExpress.XtraEditors.NavigatorButtonClickEventArgs e)
        {
            switch (e.Button.Hint)
            {
            case "添加":
                AddObject();
                break;


            case "删除":
                DeleteObject();
                break;


            case "修改":
                UpdateObject();
                break;


            case "打印":
                PrintPreview();
                break;
            }
        }
Exemple #25
0
 private void dgware_Dm_Cuahang_Ban_EmbeddedNavigator_ButtonClick(object sender, DevExpress.XtraEditors.NavigatorButtonClickEventArgs e)
 {
     //if (e.Button.ButtonType == DevExpress.XtraEditors.NavigatorButtonType.Remove)
     //{
     //    if ("" + this.gvDm_Soquy.GetFocusedRowCellValue("Id_Cuahang_Ban") != "")
     //        if (Convert.ToInt32(objMasterService.GetExistReferences("Ware_Dm_Cuahang_Ban", "Id_Cuahang_Ban", this.gvDm_Soquy.GetFocusedRowCellValue("Id_Cuahang_Ban"))) > 0)
     //        {
     //             GoobizFrame.Windows.Forms.UserMessage.Show("Msg00015", new string[] { this.Text.ToLower() });
     //            e.Handled = true;
     //        }
     //}
 }
Exemple #26
0
 private void gridControl1_EmbeddedNavigator_ButtonClick(object sender, DevExpress.XtraEditors.NavigatorButtonClickEventArgs e)
 {
 }
Exemple #27
0
 private void dgware_Dm_Hanghoa_Ban_EmbeddedNavigator_ButtonClick(object sender, DevExpress.XtraEditors.NavigatorButtonClickEventArgs e)
 {
 }
Exemple #28
0
 private void dgware_Dm_Congthuc_Phache_Chitiet_EmbeddedNavigator_ButtonClick(object sender, DevExpress.XtraEditors.NavigatorButtonClickEventArgs e)
 {
 }
        private void EmbeddedNavigator_ButtonClick(object sender, DevExpress.XtraEditors.NavigatorButtonClickEventArgs e)
        {
            if ("Load Cash".Equals(e.Button.Tag))
            {
                try
                {
                    long    lastStateChangeID = dbContext.Cashbox.Max(cb => cb.id);
                    Cashbox lastStateInfo     = dbContext.Cashbox.Where(cb => cb.id == lastStateChangeID)
                                                .Select(stateInfo => stateInfo).First();

                    Cashbox cashLoad = new Cashbox(lastStateInfo.amount_after, lastStateInfo.amount_after + 1000, DateTime.Now);
                    dbContext.Cashbox.Add(cashLoad);
                    EntityFrameworkTransactionsControl.Commit(dbContext);
                    UpdateState();
                }
                catch (Exception)
                {
                    MessageBox.Show("Cashbox State table is empty, please provide a starting amount."
                                    , "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }

            if ("Process".Equals(e.Button.Tag))
            {
                #region SaleMode
                if (saleMode == true)
                {
                    List <History> processableSales   = new List <History>();
                    int            totalSalesQuantity = 0;
                    decimal        cashGains          = 0M;
                    string         recipeHelper       = "";
                    int            recipeCount        = 1;
                    DateTime       dateOfSale         = DateTime.Now;

                    foreach (var sale in bsSalesHistory)
                    {
                        if (sale.quantity <= 0)
                        {
                            MessageBox.Show(string.Format("Skipping product {0}, because selected quantity is invalid.",
                                                          sale.product_name == null ? "[Unnamed]" : sale.product_name), "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            continue;
                        }
                        sale.Date = dateOfSale;
                        if (dbContext.Products.Any(p => p.product_name == sale.product_name))
                        {
                            var anonymousProductDetails = dbContext.Products.
                                                          Where(p => p.product_name == sale.product_name).
                                                          Select(s => new { Price = s.price_sell, Id = s.id }).ToList();
                            long quantityId = anonymousProductDetails[0].Id;

                            StockQuantities quantityAccumulator = dbContext.StockQuantities
                                                                  .Where(sq => sq.product_id == quantityId)
                                                                  .FirstOrDefault();
                            if (quantityAccumulator != null)
                            {
                                if (quantityAccumulator.quantity - sale.quantity < 0)
                                {
                                    MessageBox.Show(
                                        string.Format("There are not enough items from product [{0}] in stock to finish the sale.", sale.product_name), "Information",
                                        MessageBoxButtons.OK, MessageBoxIcon.Information);
                                    continue;
                                }
                                quantityAccumulator.quantity      -= sale.quantity;
                                quantityAccumulator.reference_date = dateOfSale;
                                EntityFrameworkTransactionsControl.Commit(dbContext);
                            }
                            else
                            {
                                MessageBox.Show(
                                    string.Format("There is no information about the quantity of product {0}. Unable to complete the sale of the current product.", sale.product_name),
                                    "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                continue;
                            }

                            totalSalesQuantity += (int)sale.quantity;
                            cashGains          += sale.quantity * anonymousProductDetails[0].Price;
                            recipeHelper       +=
                                Environment.NewLine + string.Format("{0,-3})", recipeCount++) + string.Format("{0,-27}", sale.product_name) +
                                string.Format("{0,-13}", anonymousProductDetails[0].Price) + sale.quantity + " items.";

                            processableSales.Add(sale);
                        }
                        else
                        {
                            MessageBox.Show(string.Format("Product [{0}] is invalid. Please, register it first.", sale.product_name),
                                            "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                    if (processableSales.Count > 0)
                    {
                        dbContext.History.AddRange(processableSales);
                        try
                        {
                            long lastStateChangeID = dbContext.Cashbox.Max(cb => cb.id);

                            decimal lastStateAmount = dbContext.Cashbox.
                                                      Where(cb => cb.id == lastStateChangeID).
                                                      Select(stateInfo => stateInfo).
                                                      First().amount_after;

                            dbContext.Cashbox.Add(new Cashbox(lastStateAmount, lastStateAmount + cashGains, DateTime.Now));
                            EntityFrameworkTransactionsControl.Commit(dbContext);
                        }
                        catch (Exception)
                        {
                            MessageBox.Show("Cashbox State table is empty, please provide a starting amount.",
                                            "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            EntityFrameworkTransactionsControl.Rollback(dbContext);
                            return;
                        }

                        MessageBox.Show("Sale complete!" + Environment.NewLine + Environment.NewLine +
                                        "Product                       Price        Quantity" + Environment.NewLine +
                                        "---------------------------------------------------" +
                                        recipeHelper + Environment.NewLine +
                                        "---------------------------------------------------" + Environment.NewLine +
                                        string.Format("Total Items Sold {0}.", totalSalesQuantity) + Environment.NewLine +
                                        string.Format("Total Cash Earned {0}$.", cashGains), "Sales information", MessageBoxButtons.OK, MessageBoxIcon.Information);

                        UpdateState();
                    }
                }
                #endregion
                #region BuyMode
                else
                {
                    List <StockCharge> processChargeItems = new List <StockCharge>();
                    int      totalBoughtQuantity          = 0;
                    decimal  cashToPay    = 0M;
                    string   recipeHelper = "";
                    int      recipeCount  = 1;
                    DateTime dateOfBuying = DateTime.Now;

                    foreach (var charge in bsSalesHistory)
                    {
                        if (charge.quantity <= 0)
                        {
                            MessageBox.Show(string.Format("Skipping product {0}, because the selected quantity is invalid.",
                                                          charge.product_name == null ? "[Unnamed]" : charge.product_name),
                                            "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            continue;
                        }
                        charge.Date = dateOfBuying;
                        if (dbContext.Products.Any(p => p.product_name == charge.product_name))
                        {
                            var anonymousProductDetails = dbContext.Products.
                                                          Where(p => p.product_name == charge.product_name).
                                                          Select(s => new { Id = s.id, Price = s.price_charge }).ToList();
                            long quantityId = anonymousProductDetails[0].Id;

                            StockQuantities quantityAccumulator = dbContext.StockQuantities
                                                                  .Where(sq => sq.product_id == quantityId)
                                                                  .FirstOrDefault();
                            if (quantityAccumulator != null)
                            {
                                quantityAccumulator.quantity      += charge.quantity;
                                quantityAccumulator.reference_date = dateOfBuying;
                                EntityFrameworkTransactionsControl.Commit(dbContext);
                            }
                            else
                            {
                                MessageBox.Show(
                                    string.Format("There is no information about the quantity of product {0}. Unable to complete the purchase of the current product.", charge.product_name),
                                    "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                continue;
                            }

                            totalBoughtQuantity += (int)charge.quantity;
                            cashToPay           += charge.quantity * anonymousProductDetails[0].Price;
                            recipeHelper        +=
                                Environment.NewLine + string.Format("{0,-3})", recipeCount++) + string.Format("{0,-27}", charge.product_name) +
                                string.Format("{0,-13}", anonymousProductDetails[0].Price) + charge.quantity + " items.";

                            processChargeItems.Add(new StockCharge(DateTime.Now, anonymousProductDetails[0].Id, charge.quantity));
                        }
                        else
                        {
                            MessageBox.Show(string.Format("Product [{0}] is invalid. Please, register it first.", charge.product_name),
                                            "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                    if (processChargeItems.Count > 0)
                    {
                        dbContext.StockCharge.AddRange(processChargeItems);
                        try
                        {
                            long lastStateChangeID = dbContext.Cashbox.Max(cb => cb.id);

                            decimal lastStateAmount = dbContext.Cashbox.
                                                      Where(cb => cb.id == lastStateChangeID).
                                                      Select(stateInfo => stateInfo).
                                                      First().amount_after;
                            decimal remainingCash = lastStateAmount - cashToPay;
                            if (remainingCash > 0)
                            {
                                dbContext.Cashbox.Add(new Cashbox(lastStateAmount, remainingCash, DateTime.Now));
                                EntityFrameworkTransactionsControl.Commit(dbContext);
                            }
                            else
                            {
                                MessageBox.Show("There is not enough cash to pay the charge! Aborting the operation.",
                                                "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                EntityFrameworkTransactionsControl.Rollback(dbContext);
                                return;
                            }
                        }
                        catch (Exception)
                        {
                            MessageBox.Show("Cashbox State table is empty, please provide a starting amount.",
                                            "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            EntityFrameworkTransactionsControl.Rollback(dbContext);
                            return;
                        }

                        MessageBox.Show("Purchases complete!" + Environment.NewLine + Environment.NewLine +
                                        "Product                       Price        Quantity" + Environment.NewLine +
                                        "---------------------------------------------------" +
                                        recipeHelper + Environment.NewLine +
                                        "---------------------------------------------------" + Environment.NewLine +
                                        string.Format("Total Items Bought {0}.", totalBoughtQuantity) + Environment.NewLine +
                                        string.Format("Total Cash Payed {0}$.", cashToPay),
                                        "Purchases information", MessageBoxButtons.OK, MessageBoxIcon.Information);

                        UpdateState();
                    }
                }
                #endregion
            }
        }
Exemple #30
0
 private void controlNavigator1_ButtonClick(object sender, DevExpress.XtraEditors.NavigatorButtonClickEventArgs e)
 {
     MessageBox.Show(e.Button.ButtonType.ToString());
 }