protected void btnAddResource_Click(object sender, EventArgs e) { if (IsValid) { var gridview = grdResourceList.Rows .Cast <GridViewRow>() .Where(item => item.Cells[1].Text == txtAddNewResource.Text && item.Cells[2].Text == drpNewResLocation.SelectedItem.ToString()) .Any(); if (gridview == false) { Resource res = new Resource(); res.Name = txtAddNewResource.Text; res.Location = drpNewResLocation.SelectedValue; res.Capacity = Convert.ToInt32(txtCapacity.Text); res.Description = txtNewDescription.Text; res.CategoryID = Convert.ToInt32(drpChooseCategory.SelectedValue); List <Option> optlist = new List <Option>(); foreach (ListItem item in chkblSelecetOptions.Items) { if (item.Selected) { Option opt = new Option(); opt.ID = Convert.ToInt32(item.Value); opt.Name = item.Text; optlist.Add(opt); } } ResourceHandler rs = new ResourceHandler(); var userId = Convert.ToInt32(Session[sessionNames.userID_Karbar]); rs.AddNewResource(res, optlist, userId); ClearControl(this); } else { ClientScript.RegisterStartupScript(GetType(), "alert", "alert('این نام کلاس از قبل موجود است !');", true); return; } BindData(); } }
protected void cmdSave_Click(object sender, EventArgs e) { Resource resource = new Resource(); resource.ResourceID = Convert.ToInt32(txtResourceID.Text); resource.FirstName = txtFirstName.Text; resource.LastName = txtLastName.Text; resource.SOW = txtSOW.Text; resource.PONumber = txtPONumber.Text; resource.SONumber = txtSONumber.Text; resource.StartDate = Convert.ToDateTime(txtStartDate.Text); resource.EndDate = Convert.ToDateTime(txtEndDate.Text); resource.BillingType = ddBillingType.SelectedValue; resource.ProjectName = txtProjectName.Text; resource.Location = txtLocation.Text; resource.HourlyRate = Convert.ToDouble(txtHourlyRate.Text); if (rdoActive.Checked == true) { resource.Status = "Active"; } else { resource.Status = "Non-Active"; } ResourceHandler resourceHandler = new ResourceHandler(); if (resourceHandler.AddNewResource(resource) == true) { //Response.Redirect(""); //lblResult.Text = "Resource id added succesfully"; } }