Example #1
0
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            try
            {
                labelMessage.Text = string.Empty;
                using (PoliceStationRT receiverTransfer = new PoliceStationRT())
                {
                    hdIsDelete.Value = "true";
                    hdIsEdit.Value   = "true";
                    PoliceStation policeStaion = CreatePoliceStaion();

                    if (policeStaion != null)
                    {
                        PostOfficeRT postOfficeRT = new PostOfficeRT();
                        if (postOfficeRT.IsPostOfficeExistsInPoliceStation(Convert.ToInt32(policeStaion.IID)))
                        {
                            labelMessage.Text      = "Post Office Already Exist for this Police Station";
                            labelMessage.ForeColor = System.Drawing.Color.Red;
                        }

                        else
                        {
                            receiverTransfer.UpdatePoliceStaion(policeStaion);
                            labelMessage.Text      = "Data successfully deleted...";
                            labelMessage.ForeColor = System.Drawing.Color.Green;
                        }
                    }
                    else
                    {
                        labelMessage.Text      = "Data not deleted...";
                        labelMessage.ForeColor = System.Drawing.Color.Red;
                    }
                }
                LoadPoliceStationListView();
                DohideButton();
                btnSave.Visible = true;
                ClearField();
            }
            catch (Exception ex)
            {
                labelMessage.Text      = "Error : " + ex.Message;
                labelMessage.ForeColor = System.Drawing.Color.Red;
            }
        }
Example #2
0
        protected void btnUpdate_Click(object sender, EventArgs e)
        {
            try
            {
                labelMessage.Text = string.Empty;
                using (PoliceStationRT receiverTransfer = new PoliceStationRT())
                {
                    hdIsEdit.Value = "true";
                    //hdIsDelete.Value = "false";
                    PoliceStation policeStaion = CreatePoliceStaion();

                    if (policeStaion != null)
                    {
                        //Exit If Both Police Staion Code & Name exist in Other rows
                        if ((receiverTransfer.IsPoliceStaionCodeExistInOtherRows(policeStaion.IID, policeStaion.Code, policeStaion.DistrictID)) && (receiverTransfer.IsPoliceStaionNameExistInOtherRows(policeStaion.IID, policeStaion.Code, policeStaion.DistrictID)))
                        {
                            labelMessage.Text      = "Police Staion Code " + txtCode.Text + "& Name " + txtName.Text + " Already Exists!";
                            labelMessage.ForeColor = System.Drawing.Color.Red;
                            return;
                        }
                        //Exit if Duplicate Police Station Code
                        else if (receiverTransfer.IsPoliceStationCodeExistsInOtherRows(policeStaion.IID, policeStaion.Code))
                        {
                            labelMessage.Text      = "Police Staion Code " + txtCode.Text + " Already Exists!";
                            labelMessage.ForeColor = System.Drawing.Color.Red;
                            return;
                        }

                        //Exit If Both Police Staion Code exist in Other rows
                        else if (receiverTransfer.IsPoliceStaionCodeExistInOtherRows(policeStaion.IID, policeStaion.Code, policeStaion.DistrictID))
                        {
                            labelMessage.Text      = "Police Staion Code " + txtCode.Text + " Already Exists!";
                            labelMessage.ForeColor = System.Drawing.Color.Red;
                            return;
                        }

                        //Exit If Both Police Staion Name exist in Other rows
                        else if (receiverTransfer.IsPoliceStaionNameExistInOtherRows(policeStaion.IID, policeStaion.Name, policeStaion.DistrictID))
                        {
                            labelMessage.Text      = "Police Staion Name " + txtName.Text + " Already Exists!";
                            labelMessage.ForeColor = System.Drawing.Color.Red;
                            return;
                        }
                        if (chkIsRemovedPoliceStation.Checked == true)
                        {
                            PostOfficeRT postOfficeRT = new PostOfficeRT();
                            if (postOfficeRT.IsPostOfficeExistsInPoliceStation(Convert.ToInt32(policeStaion.IID)))
                            {
                                labelMessage.Text      = "Post Office Already Exist for this Police Station";
                                labelMessage.ForeColor = System.Drawing.Color.Red;
                            }
                            else
                            {
                                receiverTransfer.UpdatePoliceStaion(policeStaion);
                                labelMessage.Text      = "Data successfully updated...";
                                labelMessage.ForeColor = System.Drawing.Color.Green;
                            }
                        }

                        else
                        {
                            receiverTransfer.UpdatePoliceStaion(policeStaion);
                            labelMessage.Text      = "Data successfully updated...";
                            labelMessage.ForeColor = System.Drawing.Color.Green;
                        }
                    }
                    else
                    {
                        labelMessage.Text      = "Data not updated...";
                        labelMessage.ForeColor = System.Drawing.Color.Red;
                    }
                }
                ClearField();
                btnSave.Visible = true;
                DohideButton();
                chkIsRemovedPoliceStation.Visible = false;

                LoadPoliceStationListView();
            }
            catch (Exception ex)
            {
                labelMessage.Text      = "Error : " + ex.Message;
                labelMessage.ForeColor = System.Drawing.Color.Red;
            }
        }