Example #1
0
        private void btnDown_Click(object sender, EventArgs e)
        {
            try
            {
                if (m_selectedIndex >= 0 && dgvFoodTypeList.Rows.Count > m_selectedIndex)
                {
                    int currentCategoryID = Int32.Parse(dgvFoodTypeList.Rows[m_selectedIndex].Cells[0].Value.ToString());

                    int currentCategoryOrder = Int32.Parse(dgvFoodTypeList.Rows[m_selectedIndex].Cells[3].Value.ToString());


                    CCategory1 oCat = new CCategory1();

                    oCat.Category1ID = currentCategoryID;

                    oCat.Category1OrderNumber = currentCategoryOrder;

                    if ((m_selectedIndex + 1) > 0 && dgvFoodTypeList.Rows.Count > (m_selectedIndex + 1))
                    {
                        int antiCategoryID = Int32.Parse(dgvFoodTypeList.Rows[(m_selectedIndex + 1)].Cells[0].Value.ToString());

                        int antiCategoryOrder = Int32.Parse(dgvFoodTypeList.Rows[(m_selectedIndex + 1)].Cells[3].Value.ToString());

                        int        iTempIndex = m_selectedIndex + 1;
                        CCategory1 oCat1      = new CCategory1();

                        oCat1.Category1ID = antiCategoryID;

                        oCat1.Category1OrderNumber = antiCategoryOrder;

                        CCategoryManager oCatManager = new CCategoryManager();

                        CResult oResult = oCatManager.UpdateCategory1Order(oCat, oCat1, false);

                        if (oResult.IsSuccess)
                        {
                            if (m_bGridFlag)
                            {
                                Int32 foodTypeID = Convert.ToInt32(cmbParentCategory.SelectedValue);
                                FillCategory1ByID(foodTypeID);

                                dgvFoodTypeList.Rows[0].Selected = false;

                                dgvFoodTypeList.Rows[iTempIndex].Selected = true;

                                m_selectedIndex = iTempIndex;

                                if (m_selectedIndex > 12)
                                {
                                    dgvFoodTypeList.FirstDisplayedScrollingRowIndex = m_selectedIndex - 12;
                                }
                            }
                            else
                            {
                                Int32 foodTypeID = Convert.ToInt32(cmbParentCategory.SelectedValue);
                                FillCategory1ByID(foodTypeID);

                                dgvFoodTypeList.Rows[0].Selected = false;

                                dgvFoodTypeList.Rows[iTempIndex].Selected = true;

                                m_selectedIndex = iTempIndex;

                                if (m_selectedIndex > 12)
                                {
                                    dgvFoodTypeList.FirstDisplayedScrollingRowIndex = m_selectedIndex - 12;
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception exp)
            {
                MessageBox.Show(exp.Message + "Error Occured. Please contact to your administrator.",
                                RMSGlobal.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }