예제 #1
0
        protected void ButtonSend_Click(object sender, EventArgs e)
        {
            if (workObject.Text == "" || typeOfWork.Text == "" || nameOfCost.Text == ""
                || measure.Text == "" || labour.Text == "" || materials.Text == "" || mechanisms.Text == "" ||
                contractor.Text == "" || customer.Text == "")
            {
                Alert.Show("Пожалуйста заполните все поля");
                return;
            }
            var db = new DBClassesDataContext();
            Plan p = new Plan {  Status = 3, Object = workObject.Text, WorkType = typeOfWork.Text,
                CostName = nameOfCost.Text, UnitName = measure.Text, Labor = labour.Text,
                Materials = materials.Text, Mechnisms = mechanisms.Text,
            };

            db.Plans.InsertOnSubmit(p);
            try
            {
                db.SubmitChanges();
                Alert.Show("Запись успешно добавлена");
            }
            catch
            {
                ClientScript.RegisterStartupScript(this.GetType(), "Ошибка", "нет записи", true);
            }
        }
예제 #2
0
 public static object UpdatePlan(Plan record)
 {
     EntityPlanManagerRepository.EF_PlanRepository rep = new EntityPlanManagerRepository.EF_PlanRepository();
     try
     {
         rep.UpdatePlan(record);
         return new { Result = "OK" };
     }
     catch (Exception ex)
     {
         return new { Result = "ERROR", Message = ex.Message };
     }
 }
예제 #3
0
        protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            GridView1.Caption = PlanName.Text;
            if (e.CommandName.Equals("Insert"))
            {
                if (first == 0)
                {
                    conn.Open();
                    SqlCommand cmd = new SqlCommand("Select ID, Object, WorkType, UnitName, CostName, Labor, Materials, Mechanisms from [Plan] where PlanID=" + planID, conn);
                    SqlDataAdapter da = new SqlDataAdapter(cmd);
                    DataSet ds = new DataSet();
                    da.Fill(ds);
                    conn.Close();

                    ds.Tables[0].Rows.Clear();
                    GridView1.DataSource = ds;
                    GridView1.DataBind();

                }
                GridViewRow row = GridView1.FooterRow;
                Label lblID = (Label)row.FindControl("ID");
                TextBox factObject = (TextBox)row.FindControl("FactObject");
                TextBox worktype = (TextBox)row.FindControl("WorkType");
                TextBox costname = (TextBox)row.FindControl("CostName");
                TextBox unitname = (TextBox)row.FindControl("UnitName");
                TextBox labor = (TextBox)row.FindControl("Labor");
                TextBox materials = (TextBox)row.FindControl("Materials");
                TextBox mechanisms = (TextBox)row.FindControl("Mechanisms");
                GridView1.EditIndex = -1;
                var db = new DBClassesDataContext();

               try
                {

                    if (planID==-1)
                    {
                        Plan plan = new Plan { Contractor = id,Object = factObject.Text, CostName = costname.Text, WorkType = worktype.Text, UnitName = unitname.Text, Labor = labor.Text, Materials = materials.Text, Mechanisms = mechanisms.Text, Customer = int.Parse(DropDownList1.SelectedValue), Status = 0, PlanID = -1, Name=PlanName.Text };
                        db.Plans.InsertOnSubmit(plan);
                        db.SubmitChanges();
                        var query =
                        from pl in db.Plans
                        where pl.PlanID==-1
                        select pl;
                        if (query != null)
                        {
                            planID = query.ToArray()[0].ID;
                        }
                        /*
                        conn.Open();
                        SqlCommand cmd = new SqlCommand("update [Plan] set Contractor="+ id +", Object="+ factObject.Text +", CostName="+ costname.Text +", WorkType="+ worktype.Text + ", UnitName="+ unitname.Text+", Labor=" + labor.Text + ", Materials=" + materials.Text + ", Mechanisms="+mechanisms.Text +", PlanID=" + planID + ", Status=" + 1 + " where PlanID=" + -1, conn);
                        cmd.ExecuteNonQuery();
                        conn.Close();
                        */
                        planID = planID + 1;
                        Plan plans = new Plan { Contractor = id, Object = factObject.Text, CostName = costname.Text, WorkType = worktype.Text, UnitName = unitname.Text, Labor = labor.Text, Materials = materials.Text, Mechanisms = mechanisms.Text, Customer = int.Parse(DropDownList1.SelectedValue), Status = 0, PlanID = planID};
                        db.Plans.InsertOnSubmit(plans);
                        db.SubmitChanges();
                        conn.Open();
                        SqlCommand cmd = new SqlCommand("DELETE [Plan] WHERE PlanID=" + -1, conn);
                        cmd.ExecuteNonQuery();
                        conn.Close();
                    }
                    else
                    {
                        Plan plans = new Plan { Contractor = id, Object = factObject.Text, CostName = costname.Text, WorkType = worktype.Text, UnitName = unitname.Text, Labor = labor.Text, Materials = materials.Text, Mechanisms = mechanisms.Text, Customer = int.Parse(DropDownList1.SelectedValue), Status = 0, PlanID = planID};
                        db.Plans.InsertOnSubmit(plans);
                        db.SubmitChanges();
                    }
                    gvbind();
                }
               catch (Exception ex)
               {
                    System.Diagnostics.Debug.Print(ex.StackTrace);
               }
            }
        }
예제 #4
0
		private void detach_Plans(Plan entity)
		{
			this.SendPropertyChanging();
			entity.Contractor1 = null;
		}
예제 #5
0
		private void attach_Plans(Plan entity)
		{
			this.SendPropertyChanging();
			entity.Contractor1 = this;
		}
예제 #6
0
 partial void DeletePlan(Plan instance);
예제 #7
0
 partial void UpdatePlan(Plan instance);
예제 #8
0
 partial void InsertPlan(Plan instance);
예제 #9
0
		private void detach_Plans(Plan entity)
		{
			this.SendPropertyChanging();
			entity.Customer1 = null;
		}
예제 #10
0
		private void attach_Plans(Plan entity)
		{
			this.SendPropertyChanging();
			entity.Customer1 = this;
		}
예제 #11
0
 public void UpdatePlan(Plan planToUpdate)
 {
     _db.Plans.InsertOnSubmit(planToUpdate);
        _db.SubmitChanges();
 }
예제 #12
0
 public void CreateNewPlan(Plan planToCreate)
 {
     _db.Plans.InsertOnSubmit(planToCreate);
     _db.SubmitChanges();
     //   return contactToCreate;
 }