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

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


                    CCategory2 oCat = new CCategory2();

                    oCat.Category2ID = iTempInt;

                    oCat.Category2Order = iTempInt3;

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

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

                        int        iTempIndex = m_selectedIndex + 1;
                        CCategory2 oCat2      = new CCategory2();

                        oCat2.Category2ID = iTempInt2;

                        oCat2.Category2Order = iTempInt4;

                        CCategoryManager oCatManager = new CCategoryManager();

                        CResult oResult = oCatManager.UpdateCategory2Order(oCat, oCat2, false);

                        if (oResult.IsSuccess)
                        {
                            if (m_bGridFlag)
                            {
                                this.FillFoodCategory();

                                dgvCategory.Rows[0].Selected = false;

                                dgvCategory.Rows[iTempIndex].Selected = true;

                                m_selectedIndex = iTempIndex;

                                if (m_selectedIndex > 12)
                                {
                                    dgvCategory.FirstDisplayedScrollingRowIndex = m_selectedIndex - 12;
                                }
                            }
                            else
                            {
                                this.FillFoodCategory();

                                dgvCategory.Rows[0].Selected = false;

                                dgvCategory.Rows[iTempIndex].Selected = true;

                                m_selectedIndex = iTempIndex;

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