protected void btnSave_Click(object sender, EventArgs e)
 {
     POLICE_STATION objpolice = new POLICE_STATION();
     if (txtPoliceCode.ReadOnly)
     {
         try
         {
             // update case
             objpolice.LoadByPrimaryKey(int.Parse(txtPoliceCode.Text));
             objpolice.DESCR = txtPoliceName.Text;
             objpolice.FK_GOVCD = short.Parse(drpGove.SelectedValue);
             objpolice.Save();
             txtPoliceCode.ReadOnly = false;
             Filter();
             //txtFilter.Text = "";
             txtPoliceCode.Text = "";
             txtPoliceName.Text = "";
             btnSave.Text = "اضافة";
         }
         catch
         {
             MHOCommon.ShowMessage("اسم القسم موجود من قبل داخل نفس المحافظة", this.Page);
         }
     }
     else
     {
         try
         {
             //Insert case
             objpolice.AddNew();
             objpolice.CD = int.Parse(txtPoliceCode.Text);
             objpolice.DESCR = txtPoliceName.Text;
             objpolice.FK_GOVCD = short.Parse(drpGove.SelectedValue);
             objpolice.Save();
             Filter();
             //txtFilter.Text = "";
             txtPoliceCode.Text = "";
             txtPoliceName.Text = "";
         }
         catch
         {
             string ss = "لقد حاولت ادخال كود موجود او اسم القسم موجود من قبل داخل نفس المحافظة";
             MHOCommon.ShowMessage(ss, this.Page);
         }
     }
 }
 /// <summary>
 /// Link Gove code click handler
 /// to allow edit this gov
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void lnkDelete_Click(object sender, EventArgs e)
 {
     LinkButton lnk = (LinkButton)sender;
     POLICE_STATION delpolice = new POLICE_STATION();
     delpolice.LoadByPrimaryKey(int.Parse(lnk.CommandArgument));
     delpolice.MarkAsDeleted();
     delpolice.Save();
     Filter();
 }
 /// <summary>
 /// Link Gove code click handler
 /// to allow edit this gov
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void lnkDelete_Click(object sender, EventArgs e)
 {
     LinkButton lnk = (LinkButton)sender;
     AREA area = new AREA();
     area.Where.FK_POLICECD.Value = int.Parse(lnk.CommandArgument);
     area.Where.FK_POLICECD.Operator = MyGeneration.dOOdads.WhereParameter.Operand.Equal;
     if (area.Query.Load())
     {
         MHOCommon.ShowMessage("لا يمكن حذف هذا القسم نظرا لما له من بيانات مرتبطة", this.Page);
     }
     else
     {
         POLICE_STATION delpolice = new POLICE_STATION();
         delpolice.LoadByPrimaryKey(int.Parse(lnk.CommandArgument));
         delpolice.MarkAsDeleted();
         delpolice.Save();
         Filter();
     }
 }