Example #1
0
 /// <summary>
 /// @author : TrungMT
 /// @CreateDate:04/03/2008
 /// @Description: Constrctor to update selected area
 /// </summary>
 public FrmAreaItem(FrmArea frmArea, Area pArea)
     : this()
 {
     mfrmArea = frmArea;
     mArea = pArea;
     //mOldArea = System.Clo
     mblnUpdate = true;
     this.Text = "Cap nhat khu vuc";
 }
Example #2
0
        /// <summary>
        /// @author : TrungMT
        /// @CreateDate:04/03/2008
        /// @Description: Delete 1 area with area_id
        /// </summary>
        /// <param name="pArea">Area</param>
        public int Delete(Area pArea)
        {
            IDbDataParameter[] parameters = {
                MakeParameter("@Area_ID", DbType.Int32, 10)
            };

            parameters[0].Value = pArea.AreaID;
            int rowAffected = 0;
            RunProcedure("sp_ADV_AREA_DELETE", parameters, out rowAffected);
            return rowAffected;
        }
Example #3
0
        /// <summary>
        /// @author : TrungMT
        /// @CreateDate:04/03/2008
        /// @Description: Create new area and return area id auto increment
        /// </summary>
        /// <param name="pArea">Area</param>
        public int Create(Area pArea)
        {
            IDbDataParameter[] parameters = {
                MakeParameter("@Code", DbType.String, 10),
                MakeParameter("@Name", DbType.String, 200),
            };

            parameters[0].Value = pArea.Code;
            parameters[1].Value = pArea.Name;
            int rowAffected = 0;
            return RunProcedure("sp_ADV_AREA_INSERT", parameters, out rowAffected);
        }
Example #4
0
        /// <summary>
        /// @author : TrungMT
        /// @CreateDate:04/03/2008
        /// @Description: Process add area in UI
        /// </summary>
        /// <param name="pArea">Area</param>
        public void AddAreaUI(Area pArea)
        {
            // Add row to grid
            DataRow row = ((DataView)mdgrArea.DataSource).Table.NewRow();
            row["AREA_ID"] = pArea.AreaID;
            row["CODE"] = pArea.Code;
            row["NAME"] = pArea.Name;
            row["##STT##"] = mdgrArea.Rows.Count + 1;
            ((DataView)mdgrArea.DataSource).Table.Rows.Add(row);

            // change current row to last row
            mdgrArea.CurrentCell = mdgrArea.Rows[mdgrArea.RowCount - 1].Cells[0];
            mdgrArea.CurrentRow.Selected = true;
            SetButtonStatus();

            //GenSTT();
        }
Example #5
0
 /// <summary>
 /// @author : TrungMT
 /// @CreateDate:04/03/2008
 /// @Description: Delete 1 area with area_id
 /// </summary>
 public int Delete(Area pArea)
 {
     PrArea area = new PrArea(Connection);
     int intRowAffected = 0;
     try
     {
         Open();
         intRowAffected = area.Delete(pArea);
         Commit();
     }
     catch (Exception exp)
     {
         Rollback();
         throw exp;
     }
     finally
     {
         Close();
     }
     return intRowAffected;
 }
Example #6
0
 /// <summary>
 /// @author : TrungMT
 /// @CreateDate:04/03/2008
 /// @Description: Insert 1 area and return area_id auto increment
 /// </summary>
 public int Add(Area pArea)
 {
     PrArea area = new PrArea(Connection);
     int intAreaID = -1;
     try
     {
         Open();
         intAreaID = area.Create(pArea);
         Commit();
     }
     catch (Exception exp)
     {
         Rollback();
         throw exp;
     }
     finally
     {
         Close();
     }
     return intAreaID;
 }
Example #7
0
 /// <summary>
 /// @author : TrungMT
 /// @CreateDate:04/03/2008
 /// @Description: Retrieves all area
 /// </summary>
 public DataSet Retrieves(Area pArea)
 {
     PrArea area = new PrArea(Connection);
     try
     {
         Open();
         return area.Search(pArea);
     }
     catch (Exception exp)
     {
         throw exp;
     }
     finally
     {
         Close();
     }
 }
Example #8
0
 /// <summary>
 /// @author : TrungMT
 /// @CreateDate:04/03/2008
 /// @Description: Get current area from grid
 /// </summary>
 /// <param name="return">Area</param>
 public Area GetCurrentArea()
 {
     // Get current row data into area
     Area area = new Area();
     area.Name = (String)mdgrArea.CurrentRow.Cells["NAME"].Value;
     area.Code = (String)mdgrArea.CurrentRow.Cells["CODE"].Value;
     area.AreaID = ((Int32)mdgrArea.CurrentRow.Cells["AREA_ID"].Value);
     // Return
     return area;
 }
Example #9
0
 /// <summary>
 /// @author : TrungMT
 /// @CreateDate:04/03/2008
 /// @Description: make search param depend on combo box
 /// </summary>
 private Area MakeSearchParam()
 {
     Area area = new Area();
     area.AreaID = -1;
     area.Code = (mcboSearch.SelectedIndex == 1) ? mtxtSearch.Text.Trim() : null;
     area.Name = (mcboSearch.SelectedIndex == 2) ? mtxtSearch.Text.Trim() : null;
     return area;
 }
Example #10
0
 /// <summary>
 /// @author : TrungMT
 /// @CreateDate:04/03/2008
 /// @Description: Update new area in UI
 /// </summary>
 /// <param name="pArea">Area</param>
 public void UpdateAreaUI(Area pArea)
 {
     // Update from data to row in grid
     mdgrArea.CurrentRow.Cells["NAME"].Value = pArea.Name;
     mdgrArea.CurrentRow.Cells["CODE"].Value = pArea.Code;
 }
Example #11
0
        /// <summary>
        /// @author : TrungMT
        /// @CreateDate:04/03/2008
        /// @Description: Update 1 area with area_id
        /// </summary>
        /// <param name="pArea">Area</param>
        public int Update(Area pArea)
        {
            IDbDataParameter[] parameters = {
                MakeParameter("@Area_ID", DbType.Int32, 10),
                MakeParameter("@Code", DbType.String, 10),
                MakeParameter("@Name", DbType.String, 200),
            };

            parameters[0].Value = pArea.AreaID;
            parameters[1].Value = pArea.Code;
            parameters[2].Value = pArea.Name;
            int rowAffected = 0;
            RunProcedure("sp_ADV_AREA_UPDATE", parameters, out rowAffected);
            return rowAffected;
        }
Example #12
0
        /// <summary>
        /// @author : TrungMT
        /// @CreateDate:04/03/2008
        /// @Description: Searh all area
        /// </summary>
        public DataSet Search(Area pArea)
        {
            IDbDataParameter[] parameters = {
                MakeParameter("@Area_ID", DbType.Int32, 10),
                MakeParameter("@Code", DbType.String, 10),
                MakeParameter("@Name", DbType.String, 200)
            };

            parameters[0].Value = (pArea.AreaID < 0) ?   (object) DBNull.Value : (object) pArea.AreaID;
            parameters[1].Value = (pArea.Code == null) ? (object) DBNull.Value : (object)pArea.Code;
            parameters[2].Value = (pArea.Name == null) ? (object) DBNull.Value : (object)pArea.Name;
            return RunProcedure("sp_ADV_AREA_SELECT_SEARCH", parameters, "ADV_AREA");
        }