コード例 #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
ファイル: ViewPlan.aspx.cs プロジェクト: hjujgfg/DataViewer
 protected void Button2_Click(object sender, EventArgs e)
 {
     var db = new DBClassesDataContext();
     var query =
         from plan in db.Plans
         where plan.ID == planindex
         select plan;
     query.ToArray()[0].Status = 2;
     try
     {
         db.SubmitChanges();
     }
     catch (Exception exception)
     {
         Console.WriteLine(exception.StackTrace);
     }
     viewPlan();
     string email;
     try
     {
         email = contr[0].Email;
     }
     catch (Exception)
     {
         email = "";
     }
     ClientScript.RegisterStartupScript(this.GetType(), "mailto",
        "<script type = 'text/javascript'>parent.location='mailto:" + email +
        "'</script>");
 }
コード例 #3
0
ファイル: ViewPlan.aspx.cs プロジェクト: hjujgfg/DataViewer
 protected void Button1_Click(object sender, EventArgs e)
 {
     var db = new DBClassesDataContext();
     var query =
         from plan in db.Plans
         where plan.ID == planindex
         select plan;
     query.ToArray()[0].Status = 1;
     try
     {
         db.SubmitChanges();
     }
     catch (Exception exception)
     {
         Console.WriteLine(exception.StackTrace);
     }
     viewPlan();
 }
コード例 #4
0
ファイル: Register.aspx.cs プロジェクト: hjujgfg/TechUp
        protected void regUser(object sender, EventArgs e)
        {
            TextBox userName = (TextBox)this.RegisterUser.CreateUserStep.ContentTemplateContainer.FindControl("UserName");
            TextBox email = (TextBox)this.RegisterUser.CreateUserStep.ContentTemplateContainer.FindControl("Email");
            TextBox password = (TextBox)this.RegisterUser.CreateUserStep.ContentTemplateContainer.FindControl("Password");
            TextBox password2 = (TextBox)this.RegisterUser.CreateUserStep.ContentTemplateContainer.FindControl("ConfirmPassword");

            if (userName.Text == "" || email.Text == "" || password.Text == ""
            || password2.Text == "")
            {
                Alert.Show("Пожалуйста, заполните все поля");
                return;
            }
            var db = new DBClassesDataContext();
            Contractor c = null;
            Customer cus = null;
            if (RadioButton1.Checked == true)//Заказчик
            {
                cus = new Customer { Name = userName.Text, Email = email.Text, Password = password.Text };
                db.Customers.InsertOnSubmit(cus);
            }
            else //Подрядчик
            {
                c = new Contractor { Name = userName.Text, Email = email.Text, Password = password.Text };
                db.Contractors.InsertOnSubmit(c);
            }
            try
            {
                db.SubmitChanges();
                Alert.Show("Запись успешно добавлена");
            }
            catch
            {
                ClientScript.RegisterStartupScript(this.GetType(), "Ошибка", "нет записи", true);
            }
            Response.Redirect("http://.../Default.aspx");
        }
コード例 #5
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);
               }
            }
        }
コード例 #6
0
ファイル: NewPlan.aspx.cs プロジェクト: hjujgfg/TechUp
 protected void gvbind()
 {
     conn.Open();
     SqlCommand cmd = new SqlCommand("Select ID, FactObject, WorkType, UnitName, CostName, Labor, Materials, Mechanisms from Fact where FactID=" + planID, conn);
     SqlDataAdapter da = new SqlDataAdapter(cmd);
     DataSet ds = new DataSet();
     da.Fill(ds);
     conn.Close();
     if (ds.Tables[0].Rows.Count > 0)
     {
         GridView1.DataSource = ds;
         GridView1.DataBind();
     }
     else
     {
         // (Table1.Rows.Count > 1)
         {
             var db = new DBClassesDataContext();
             var query =
                 from plan in db.Plans
                 where plan.PlanID == planID
                 select plan;
             Plan[] plans = query.ToArray();
             List<Fact> facts = new List<Fact>();
             for (int i = 0; i < plans.Length; i++)
             {
                 Fact f = new Fact { FactID = planID, CostName = plans[i].CostName, FactObject = plans[i].Object, Labor = plans[i].Labor, Materials = plans[i].Materials, Mechanisms = plans[i].Mechanisms, UnitName = plans[i].UnitName, WorkType = plans[i].WorkType, Status = 1 };
                 facts.Add(f);
             }
             db.Facts.InsertAllOnSubmit<Fact>(facts);
             try
             {
                 db.SubmitChanges();
             }
             catch (Exception ex)
             {
                 System.Diagnostics.Debug.Print(ex.StackTrace);
             }
             conn.Open();
             cmd = new SqlCommand("Select ID, FactObject, WorkType, UnitName, CostName, Labor, Materials, Mechanisms from Fact where FactID=" + planID, conn);
             da = new SqlDataAdapter(cmd);
             ds = new DataSet();
             da.Fill(ds);
             conn.Close();
             if (ds.Tables[0].Rows.Count > 0)
             {
                 GridView1.DataSource = ds;
                 GridView1.DataBind();
             }
             else
             {
                 ds.Tables[0].Rows.Add(ds.Tables[0].NewRow());
                 GridView1.DataSource = ds;
                 GridView1.DataBind();
                 int columncount = GridView1.Rows[0].Cells.Count;
                 GridView1.Rows[0].Cells.Clear();
                 GridView1.Rows[0].Cells.Add(new TableCell());
                 GridView1.Rows[0].Cells[0].ColumnSpan = columncount;
                 GridView1.Rows[0].Cells[0].Text = "Ошибка";
             }
         }
     }
 }
コード例 #7
0
ファイル: Login.aspx.cs プロジェクト: hjujgfg/TechUp
        protected void registerCustomer(object sender, EventArgs e)
        {
            string name = CustomerName.Text;
             string email = CustomerEmail.Text;
             string pas = CustomerPassword.Text;
             string pas2 = CustomerPassword2.Text;
             if (!pas.Equals(pas2))
             {
                 Alert.Show("Пароли не совпадают!");
                 return;
             }
              if (name == "" || email == "" || pas == ""
             || pas2 == "")
            {
                Alert.Show("Пожалуйста, заполните все поля");
                return;
            }
              if (pas.Length < 6)
              {
                  Alert.Show("Пароль должен состоять не менее чем из 6 символов");
                  return;
              }
            var db = new DBClassesDataContext();

               Customer c = new Customer { Name = name, Email = email, Password = pas, Info = "", Address=""};
                db.Customers.InsertOnSubmit(c);
            try
            {
                db.SubmitChanges();
                //отправляем письмо
                string emailString = email;
                string subject = "Регистрация в системе";
                string text = "Здравствуйте,  " + name + "!" + ".\n" +
                "Вы успешно зарегистрированы в системе взаимодействия подрядчиков и заказчиков." + ".\n" +
                "Ваша роль в системе: заказчик " + "\nС уважением, администрация сервиса.";
                sendEmail(emailString, subject, text);
            }
            catch (Exception ex)
            {
                ClientScript.RegisterStartupScript(this.GetType(), "Ошибка", "нет записи", true);
                System.Diagnostics.Debug.Print(ex.StackTrace);
                return;
            }
            try
            {
                Membership.CreateUser(email, pas);
                FormsAuthentication.SetAuthCookie(email, true);
                Roles.AddUserToRole(email, Global.customerRole);
                Response.Redirect("../ViewPlan.aspx");
                //Alert.Show("Запись успешно добавлена");
            }
            catch (Exception ex)
            {
                Alert.Show("Пользователь с таким email уже зарегистрирован!");
            }
        }
コード例 #8
0
 protected void sendFact_Click(object sender, EventArgs e)
 {
     int tmpID;
     List<Fact> facts = new List<Fact>();
     foreach (TableRow row in Table.Rows)
     {
         if (row.Cells[0].Text == "№  ") continue;
         try
         {
             tmpID = int.Parse(row.Cells[0].Text);
             TextBox lab = (TextBox)row.Cells[6].Controls[0];
             TextBox mat = (TextBox)row.Cells[8].Controls[0];
             TextBox mech = (TextBox)row.Cells[10].Controls[0];
             Fact tmp = new Fact
             {
                 FactObject = row.Cells[1].Text,
                 WorkType = row.Cells[2].Text,
                 UnitName = row.Cells[3].Text,
                 CostName = row.Cells[4].Text,
                 Labor = lab.Text,
                 Materials = mat.Text,
                 Mechanisms = mech.Text,
                 ExtPlanID = tmpID,
                 FactID = planID
             };
             facts.Add(tmp);
         }
         catch (Exception ex)
         {
             System.Diagnostics.Debug.Print(ex.StackTrace);
         }
     }
     try
     {
         var db = new DBClassesDataContext();
         var query =
             from fact in db.Facts
             where fact.FactID == planID
             select fact;
         Fact[] factsToRemove = query.ToArray();
         db.Facts.DeleteAllOnSubmit(factsToRemove);
         db.SubmitChanges();
         db.Facts.InsertAllOnSubmit(facts);
         db.SubmitChanges();
         String updatePlan = "UPDATE [Plan] SET Status=5 WHERE PlanID=" + planID;
         conn.Open();
         SqlCommand cmd = new SqlCommand(updatePlan, conn);
         cmd.ExecuteNonQuery();
         conn.Close();
         Alert.Show("Фактические значения успешно отправлены!");
         Response.Redirect("NewPlan.aspx");
     }
     catch (Exception ex)
     {
         System.Diagnostics.Debug.Print(ex.StackTrace);
     }
 }