예제 #1
0
        protected void gvvendor_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            Label   lblvendorId       = (Label)gvvendor.Rows[e.RowIndex].FindControl("lblvendorId");
            TextBox txtEditVendorName = (TextBox)gvvendor.Rows[e.RowIndex].FindControl("txtEditVendorName");
            TextBox txtEditAddress    = (TextBox)gvvendor.Rows[e.RowIndex].FindControl("txtEditAddress");
            TextBox txtEditContactNo  = (TextBox)gvvendor.Rows[e.RowIndex].FindControl("txtEditContactNo");
            TextBox txtEditBillNo     = (TextBox)gvvendor.Rows[e.RowIndex].FindControl("txtEditBillNo");


            Domain.Vendor existing = venderrepo.GetById(Convert.ToInt32(lblvendorId.Text));
            if (txtEditVendorName.Text != ("") && txtEditAddress.Text != ("") && txtEditContactNo.Text != ("") && txtEditBillNo.Text != (""))
            {
                if (existing != null)
                {
                    existing.VendorName       = txtEditVendorName.Text;
                    existing.Address          = txtEditAddress.Text;
                    existing.ContactNo        = txtEditContactNo.Text;
                    existing.BillNo           = txtEditBillNo.Text;
                    existing.LastUpdatedBy    = "admin";
                    existing.LastUpdationTime = DateTime.Now;
                    existing.TenantId         = tenantId;
                }


                venderrepo.Edit(existing);
                venderrepo.Save();
                gvvendor.EditIndex = -1;
                BindData();
                ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('Vendor Sucessfully Updated');", true);
            }
            else
            {
                ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('Null Filled Not allowed');", true);
            }
            //conn.Open();
            //string cmdstr = "update EmployeeDetails set name=@name,designation=@designation,city=@city,country=@country where empid=@empid";
            //SqlCommand cmd = new SqlCommand(cmdstr, conn);
            //cmd.Parameters.AddWithValue("@empid", lblEditEmpID.Text);
            //cmd.Parameters.AddWithValue("@name", txtEditName.Text);
            //cmd.Parameters.AddWithValue("@designation", txtEditDesignation.Text);
            //cmd.Parameters.AddWithValue("@city", txtEditCity.Text);
            //cmd.Parameters.AddWithValue("@country", txtEditCountry.Text);
            //cmd.ExecuteNonQuery();
            //conn.Close();
            //gvvendor.EditIndex = -1;
            //BindData();
        }
예제 #2
0
        protected void gvvendor_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            try
            {
                if (e.CommandName.Equals("ADD"))
                {
                    TextBox txtAddvendorName = (TextBox)gvvendor.FooterRow.FindControl("txtAddVendorName");
                    TextBox txtAddAddress    = (TextBox)gvvendor.FooterRow.FindControl("txtAddAddress");
                    TextBox txtAddContactNo  = (TextBox)gvvendor.FooterRow.FindControl("txtAddContactNo");
                    TextBox txtAddBillNo     = (TextBox)gvvendor.FooterRow.FindControl("txtAddBillNo");


                    if (txtAddvendorName.Text != ("") && txtAddAddress.Text != ("") && txtAddContactNo.Text != ("") && txtAddBillNo.Text != (""))
                    {
                        Domain.Vendor vendor = new Domain.Vendor()
                        {
                            VendorName       = txtAddvendorName.Text,
                            Address          = txtAddAddress.Text,
                            ContactNo        = txtAddContactNo.Text,
                            BillNo           = txtAddBillNo.Text,
                            CreationTime     = DateTime.Now,
                            LastUpdationTime = DateTime.Now,
                            CreatedBy        = "admin",
                            LastUpdatedBy    = "admin",
                            TenantId         = tenantId,
                        };


                        venderrepo.Add(vendor);
                        venderrepo.Save();
                        BindData();
                        ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('Vendor Sucessfully Inserted');", true);
                        BindData();
                    }

                    else
                    {
                        ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('Null Filled Not allowed');", true);
                    }
                }
            }
            catch (Exception ex)
            {
                Response.Write(ex.Message);
            }
        }