コード例 #1
0
        protected void RequestGrid_DeleteCommand(object sender, GridCommandEventArgs e)
        {
            GridDataItem item      = e.Item as GridDataItem;
            string       requestno = item["RequestNo"].Text;
            CheckBox     chk       = item["Submitted"].Controls[0] as CheckBox;
            bool         submitted = chk.Checked;

            if (submitted)
            {
                ScriptManager.RegisterStartupScript(this, this.GetType(), "", "toastr.error('Request Submitted...Cannot Delete', 'Error');", true);
                return;
            }
            using (SqlConnection connection = new SqlConnection(connectionString))
            {
                using (SqlCommand command = new SqlCommand("Delete from tblLabourRequestForm where RequestNo = @RequestNo", connection))
                {
                    command.Parameters.Add("@RequestNo", SqlDbType.Int).Value = requestno;
                    try
                    {
                        connection.Open();
                        rows = command.ExecuteNonQuery();
                        if (rows == 1)
                        {
                            ScriptManager.RegisterStartupScript(this, this.GetType(), "", "toastr.success('Deleted Successfully', 'Success');", true);
                            RequestGrid.Rebind();
                        }
                    }
                    catch (Exception ex)
                    {
                        ScriptManager.RegisterStartupScript(this, this.GetType(), "", "toastr.error('" + ex.Message.Replace("'", "").Replace("\r\n", "") + "', 'Error');", true);
                    }
                }
            }
        }
コード例 #2
0
        protected void btnUpdate_Click(object sender, EventArgs e)
        {
            string query = "update tblLabourRequest set Request = @Request, DLECompanyId = @DLECompanyId where RequestNo = @RequestNo";

            using (SqlConnection connection = new SqlConnection(connectionString))
            {
                using (SqlCommand command = new SqlCommand(query, connection))
                {
                    command.Parameters.Add("@Request", SqlDbType.VarChar).Value   = txtRequest1.Text;
                    command.Parameters.Add("@DLECompanyId", SqlDbType.Int).Value  = dlCompany1.SelectedValue;
                    command.Parameters.Add("@RequestNo", SqlDbType.VarChar).Value = txtRequestNo1.Text;
                    try
                    {
                        connection.Open();
                        rows = command.ExecuteNonQuery();
                        if (rows == 1)
                        {
                            ScriptManager.RegisterStartupScript(this, this.GetType(), "", "toastr.success('Updated Successfully', 'Success');", true);
                            //ScriptManager.RegisterStartupScript(this, this.GetType(), "popup", "closeeditModal();", true);

                            btnSubmit1.Enabled = true;
                            RequestGrid.Rebind();
                        }
                    }
                    catch (Exception ex)
                    {
                        ScriptManager.RegisterStartupScript(this, this.GetType(), "ex", "toastr.error('" + ex.Message.Replace("'", "").Replace("\r\n", "") + "', 'Error');", true);
                    }
                }
            }
        }
コード例 #3
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            string query = "spAddLabourRequest";

            using (SqlConnection connection = new SqlConnection(connectionString))
            {
                using (SqlCommand command = new SqlCommand(query, connection))
                {
                    command.CommandType = CommandType.StoredProcedure;
                    command.Parameters.Add("@DLECompanyId", SqlDbType.Int).Value          = dlCompany.SelectedValue;
                    command.Parameters.Add("@Request", SqlDbType.VarChar).Value           = txtRequest.Text;
                    command.Parameters.Add("@CreatedBy", SqlDbType.VarChar).Value         = User.Identity.Name;
                    command.Parameters.Add("@RequestNo", SqlDbType.VarChar, 20).Direction = ParameterDirection.Output;
                    command.Parameters.Add("@return_value", SqlDbType.Int).Direction      = ParameterDirection.ReturnValue;
                    try
                    {
                        connection.Open();
                        command.ExecuteNonQuery();
                        int retVal = Convert.ToInt16(command.Parameters["@return_value"].Value);
                        if (retVal == 0)
                        {
                            ScriptManager.RegisterStartupScript(this, this.GetType(), "", "toastr.success('Saved Successfully', 'Success');", true);
                            txtRequestNo.Text = command.Parameters["@RequestNo"].Value.ToString();

                            btnSubmit.Enabled = true;
                            RequestGrid.Rebind();
                        }
                    }
                    catch (Exception ex)
                    {
                        ScriptManager.RegisterStartupScript(this, this.GetType(), "", "toastr.error('" + ex.Message.Replace("'", "").Replace("\r\n", "") + "', 'Error');", true);
                    }
                }
            }
        }
コード例 #4
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            using (SqlConnection connection = new SqlConnection(connectionString))
            {
                using (SqlCommand command = new SqlCommand("spSubmitLabourRequest", connection))
                {
                    command.CommandType = CommandType.StoredProcedure;
                    command.Parameters.Add("@dleCompanyId", SqlDbType.Int).Value = dlCompany.SelectedValue;
                    command.Parameters.Add("@dleCompanyName", SqlDbType.VarChar, 100).Direction = ParameterDirection.Output;
                    command.Parameters.Add("@requestEmail", SqlDbType.VarChar, 50).Direction    = ParameterDirection.Output;
                    command.Parameters.Add("@RequestNo", SqlDbType.VarChar).Value    = txtRequestNo.Text;
                    command.Parameters.Add("@submittedBy", SqlDbType.VarChar).Value  = Context.User.Identity.Name;
                    command.Parameters.Add("@return_value", SqlDbType.Int).Direction = ParameterDirection.ReturnValue;
                    try
                    {
                        connection.Open();
                        command.ExecuteNonQuery();
                        int retVal = Convert.ToInt16(command.Parameters["@return_value"].Value);
                        if (retVal == 0)
                        {
                            ScriptManager.RegisterStartupScript(this, this.GetType(), "", "toastr.success('Submitted Successfully', 'Success');", true);
                            ScriptManager.RegisterStartupScript(this, this.GetType(), "popup", "closenewModal();", true);
                            RequestGrid.Rebind();

                            sendEmail(command.Parameters["@dleCompanyName"].Value.ToString(), command.Parameters["@requestEmail"].Value.ToString(), txtRequestNo.Text, txtRequest.Text);

                            txtRequestNo.Text = "";
                            txtRequest.Text   = "";
                            btnSubmit.Enabled = false;
                        }
                    }
                    catch (Exception ex)
                    {
                        ScriptManager.RegisterStartupScript(this, this.GetType(), "ex", "toastr.error('" + ex.Message.Replace("'", "").Replace("\r\n", "") + "', 'Error');", true);
                    }
                }
            }
        }
コード例 #5
0
 protected void txtSearchReq_TextChanged(object sender, EventArgs e)
 {
     RequestGrid.Rebind();
 }