コード例 #1
0
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            try
            {
                labelMessage.Text = string.Empty;
                using (DivisionOrStateRT receiverTransfer = new DivisionOrStateRT())
                {
                    //hdIsDelete.Value = "true";
                    hdIsEdit.Value = "true";
                    DivisionOrState divisionOrState = CreateDivsionOrState();

                    if (divisionOrState != null)
                    {
                        DistrictRT districtRT = new DistrictRT();

                        if (districtRT.IsDistrictExistsInDivision(Convert.ToInt32(divisionOrState.IID)))
                        {
                            labelMessage.Text      = "District Already Exist For This Division Or State";
                            labelMessage.ForeColor = System.Drawing.Color.Red;
                        }

                        else
                        {
                            receiverTransfer.UpdateDivisionOrState(divisionOrState);
                            labelMessage.Text      = "Data successfully deleted...";
                            labelMessage.ForeColor = System.Drawing.Color.Green;
                        }
                    }
                    else
                    {
                        labelMessage.Text      = "Data not deleted...";
                        labelMessage.ForeColor = System.Drawing.Color.Red;
                    }
                }
                LoadDivisionOrState();
                ClearField();
            }
            catch (Exception ex)
            {
                labelMessage.Text      = "Error : " + ex.Message;
                labelMessage.ForeColor = System.Drawing.Color.Red;
            }
        }
コード例 #2
0
        protected void btnUpdate_Click(object sender, EventArgs e)
        {
            try
            {
                labelMessage.Text = string.Empty;
                using (DivisionOrStateRT receiverTransfer = new DivisionOrStateRT())
                {
                    hdIsEdit.Value = "true";
                    DistrictRT districtRT = new DistrictRT();
                    //hdIsDelete.Value = "false";
                    DivisionOrState divisionOrState = CreateDivsionOrState();

                    if (divisionOrState != null)
                    {
                        if ((receiverTransfer.IsDivOrStateCodeExistInOterRows(divisionOrState.IID, divisionOrState.Code, divisionOrState.CountryID)) && (receiverTransfer.IsDivOrStateNameExistInOterRows(divisionOrState.IID, divisionOrState.Name, divisionOrState.CountryID)))
                        {
                            labelMessage.Text      = "Division Or State Code " + txtCode.Text + " & Name " + txtName.Text + " Already Exists!";
                            labelMessage.ForeColor = System.Drawing.Color.Red;
                            return;
                        }
                        else if (receiverTransfer.IsDivOrStateCodeExisInOterRow(divisionOrState.IID, divisionOrState.Code))
                        {
                            labelMessage.Text      = "Division Or State Code " + txtCode.Text + " Already Exists!";
                            labelMessage.ForeColor = System.Drawing.Color.Red;
                            return;
                        }

                        else if (receiverTransfer.IsDivOrStateCodeExistInOterRows(divisionOrState.IID, divisionOrState.Code, divisionOrState.CountryID))
                        {
                            labelMessage.Text      = "Division Or State Code " + txtCode.Text + " Already Exists!";
                            labelMessage.ForeColor = System.Drawing.Color.Red;
                            return;
                        }

                        else if (receiverTransfer.IsDivOrStateNameExistInOterRows(divisionOrState.IID, divisionOrState.Name, divisionOrState.CountryID))
                        {
                            labelMessage.Text      = "Division Or State Name " + txtName.Text + " Already Exists!";
                            labelMessage.ForeColor = System.Drawing.Color.Red;
                            return;
                        }

                        if (chkIsRemovedDivOrState.Checked == true)
                        {
                            if (districtRT.IsDistrictExistsInDivision(Convert.ToInt32(divisionOrState.IID)))
                            {
                                labelMessage.Text      = "District already exist for this Division Or State";
                                labelMessage.ForeColor = System.Drawing.Color.Red;
                            }
                            else
                            {
                                receiverTransfer.UpdateDivisionOrState(divisionOrState);
                                labelMessage.Text      = "Data successfully updated...";
                                labelMessage.ForeColor = System.Drawing.Color.Green;
                            }
                        }
                        else
                        {
                            receiverTransfer.UpdateDivisionOrState(divisionOrState);
                            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();
                chkIsRemovedDivOrState.Visible = false;

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