コード例 #1
0
ファイル: CreatePlan.aspx.cs プロジェクト: hjujgfg/DataViewer
        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
ファイル: DBClasses.designer.cs プロジェクト: hjujgfg/TechUp
		private void detach_Plans(Plan entity)
		{
			this.SendPropertyChanging();
			entity.Contractor1 = null;
		}
コード例 #5
0
ファイル: DBClasses.designer.cs プロジェクト: hjujgfg/TechUp
		private void attach_Plans(Plan entity)
		{
			this.SendPropertyChanging();
			entity.Contractor1 = this;
		}
コード例 #6
0
ファイル: DBClasses.designer.cs プロジェクト: hjujgfg/TechUp
 partial void DeletePlan(Plan instance);
コード例 #7
0
ファイル: DBClasses.designer.cs プロジェクト: hjujgfg/TechUp
 partial void UpdatePlan(Plan instance);
コード例 #8
0
ファイル: DBClasses.designer.cs プロジェクト: hjujgfg/TechUp
 partial void InsertPlan(Plan instance);
コード例 #9
0
ファイル: DBClasses.designer.cs プロジェクト: hjujgfg/TechUp
		private void detach_Plans(Plan entity)
		{
			this.SendPropertyChanging();
			entity.Customer1 = null;
		}
コード例 #10
0
ファイル: DBClasses.designer.cs プロジェクト: hjujgfg/TechUp
		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;
 }