예제 #1
0
파일: FoodTypeCtl.cs 프로젝트: Jusharra/RMS
        private void dgvFoodTypeList_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e)
        {
            if (e.RowIndex == -1)
            {
                return;
            }
            try
            {
                if (e.ColumnIndex == 4)
                {
                    Int32  foodTypeID   = Convert.ToInt32("0" + dgvFoodTypeList.Rows[e.RowIndex].Cells[0].Value);
                    string foodTypeName = Convert.ToString(dgvFoodTypeList.Rows[e.RowIndex].Cells[1].Value);

                    EditFoodTypeCtl objFoodType = new EditFoodTypeCtl(foodTypeID, foodTypeName);
                    objFoodType.Parent = this.ParentForm;
                    UserControlManager.UserControls.Push(this);
                    Panel pnl = (Panel)this.ParentForm.Controls["pnlContext"];

                    string s = pnl.Name;

                    objFoodType.ParentForm.Controls[s].Controls.Clear();
                    objFoodType.ParentForm.Controls[s].Controls.Add(objFoodType);
                }

                else if (e.ColumnIndex == 5)
                {
                    if (MessageBox.Show("Are you sure you want to delete the selected food type?", RMSGlobal.MessageBoxTitle, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                    {
                        int foodTypeID = 0;

                        bool bTempBool = Int32.TryParse(dgvFoodTypeList.Rows[e.RowIndex].Cells[0].Value.ToString(), out foodTypeID);

                        if (bTempBool)
                        {
                            CCategory1 objFoodType = new CCategory1();

                            objFoodType.Category1ID = foodTypeID;
                            CCategoryManager oManager = new CCategoryManager();

                            CResult oResult = oManager.DeleteCat1(objFoodType);

                            if (oResult.IsSuccess)
                            {
                                dgvFoodTypeList.Rows.RemoveAt(e.RowIndex);
                            }
                        }
                    }
                }
            }
            catch (Exception exp)
            {
                throw exp;
            }
        }
예제 #2
0
파일: FoodTypeCtl.cs 프로젝트: Jusharra/RMS
        private void dgvFoodTypeList_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e)
        {
            if (e.RowIndex == -1)
            {
                return;
            }
            try
            {
                if (e.ColumnIndex == 4)
                {
                    Int32 foodTypeID = Convert.ToInt32("0" + dgvFoodTypeList.Rows[e.RowIndex].Cells[0].Value);
                    string foodTypeName = Convert.ToString(dgvFoodTypeList.Rows[e.RowIndex].Cells[1].Value);

                    EditFoodTypeCtl objFoodType = new EditFoodTypeCtl(foodTypeID, foodTypeName);
                    objFoodType.Parent = this.ParentForm;
                    UserControlManager.UserControls.Push(this);
                    Panel pnl = (Panel)this.ParentForm.Controls["pnlContext"];

                    string s = pnl.Name;

                    objFoodType.ParentForm.Controls[s].Controls.Clear();
                    objFoodType.ParentForm.Controls[s].Controls.Add(objFoodType);
                }

                else if (e.ColumnIndex == 5)
                {
                    if (MessageBox.Show("Are you sure you want to delete the selected food type?", RMSGlobal.MessageBoxTitle, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                    {
                        int foodTypeID = 0;

                        bool bTempBool = Int32.TryParse(dgvFoodTypeList.Rows[e.RowIndex].Cells[0].Value.ToString(), out foodTypeID);

                        if (bTempBool)
                        {
                            CCategory1 objFoodType = new CCategory1();

                            objFoodType.Category1ID = foodTypeID;
                            CCategoryManager oManager = new CCategoryManager();

                            CResult oResult = oManager.DeleteCat1(objFoodType);

                            if (oResult.IsSuccess)
                            {
                                dgvFoodTypeList.Rows.RemoveAt(e.RowIndex);
                            }
                        }
                    }
                }
            }
            catch (Exception exp)
            {
                throw exp;
            }
        }