示例#1
0
        public Project Create(string name, PlanDate startdate)
        {
            Project newProject = new Project(name, startdate);

            _repository.Add(newProject);
            return(newProject);
        }
示例#2
0
        private void loadPlanDate(string usernameTo, string usernameFrom, List <DateRequest> dateRequests)
        {
            User tempUser   = new User();
            int  userIDTo   = tempUser.getUserID(usernameTo);
            int  userIDFrom = tempUser.getUserID(usernameFrom);

            foreach (DateRequest dateRequest in dateRequests)
            {
                if (dateRequest.UserIDFrom == userIDFrom && dateRequest.UserIDTo == userIDTo)
                {
                    string      url      = "https://localhost:44369/api/DatingService/Profiles/GetDatePlanDetails/" + GlobalData.APIKey + "/" + userIDFrom + "/" + userIDTo;
                    WebRequest  request  = WebRequest.Create(url);
                    WebResponse response = request.GetResponse();

                    Stream       theDataStream = response.GetResponseStream();
                    StreamReader reader        = new StreamReader(theDataStream);
                    string       data          = reader.ReadToEnd();
                    reader.Close();
                    response.Close();

                    JavaScriptSerializer js          = new JavaScriptSerializer();
                    PlanDate             planDateObj = js.Deserialize <PlanDate>(data);

                    txtDate.Text        = planDateObj.Date;
                    txtTime.Text        = planDateObj.Time;
                    txtDescription.Text = planDateObj.Description;

                    planDate.Visible = true;
                }
            }
        }
        public PlanDate getDatePlanDetails(string APIKey, int userIDFrom, int userIDTo)
        {
            if (APIKey == this.APIKey)
            {
                DBConnect  objDB  = new DBConnect();
                SqlCommand objCmd = new SqlCommand();
                objCmd.CommandType = CommandType.StoredProcedure;
                objCmd.CommandText = "TP_GetDatePlanDetails";
                objCmd.Parameters.AddWithValue("@requestTo", userIDTo);
                objCmd.Parameters.AddWithValue("@requestFrom", userIDFrom);
                DataSet detailsDS = objDB.GetDataSetUsingCmdObj(objCmd);

                PlanDate planDate = new PlanDate();
                if (detailsDS.Tables[0].Rows.Count > 0)
                {
                    planDate.Date        = detailsDS.Tables[0].Rows[0]["Date"].ToString();
                    planDate.Time        = detailsDS.Tables[0].Rows[0]["Time"].ToString();
                    planDate.Description = detailsDS.Tables[0].Rows[0]["Description"].ToString();
                    return(planDate);
                }
                else
                {
                    return(planDate);
                }
            }
            else
            {
                return(new PlanDate());
            }
        }
示例#4
0
        void on_btnOk_clicked(object sender, EventArgs args)
        {
            string   t         = projektName.Text;
            PlanDate startdate = new PlanDate(calStartdate.Day, calStartdate.Month, calStartdate.Year);

            _factory.Create(t, startdate);
            Destroy();
        }
示例#5
0
        protected void btnSavePlan_Click(object sender, EventArgs e)
        {
            lblErrorMsg.Text    = string.Empty;
            lblErrorMsg.Visible = false;

            if (validatePlanDetails())
            {
                PlanDate datePlan = new PlanDate();
                datePlan.Date        = txtDate.Text;
                datePlan.Time        = txtTime.Text;
                datePlan.Description = txtDescription.Text;

                JavaScriptSerializer js = new JavaScriptSerializer();
                string jsonDatePlan     = js.Serialize(datePlan);

                try
                {
                    string     url     = "https://localhost:44369/api/DatingService/Profiles/ModifyDatePlan/" + GlobalData.APIKey + "/" + Session["PlanDateUsernameTo"].ToString() + "/" + Session["PlanDateUsernameFrom"].ToString();
                    WebRequest request = WebRequest.Create(url);
                    request.Method        = "PUT";
                    request.ContentLength = jsonDatePlan.Length;
                    request.ContentType   = "application/json";

                    //Write the JSON data to the Web Request
                    StreamWriter writer = new StreamWriter(request.GetRequestStream());
                    writer.Write(jsonDatePlan);
                    writer.Flush();
                    writer.Close();

                    //Read the data from the Web Response
                    WebResponse  response      = request.GetResponse();
                    Stream       theDataStream = response.GetResponseStream();
                    StreamReader reader        = new StreamReader(theDataStream);
                    string       data          = reader.ReadToEnd();
                    reader.Close();
                    response.Close();

                    if (data == "true")
                    {
                        btnClose.Text       = "Close";
                        lblErrorMsg.Text   += "Date Plan saved successfully. <br />";
                        lblErrorMsg.Visible = true;
                    }
                    else
                    {
                        lblErrorMsg.Text   += "*A problem occured while updating your date plan. <br />";
                        lblErrorMsg.Visible = true;
                    }
                }
                catch (Exception ex)
                {
                    lblErrorMsg.Text   += "*Error: " + ex.Message + "<br />";
                    lblErrorMsg.Visible = true;
                }
            }
        }
示例#6
0
        private void button2_Click(object sender, EventArgs e)
        {
            if (this.dataGridView1.Rows.Count == 0)
            {
                MessageBox.Show("请先选择需要生成的记录");
            }
            else if (comboBox3.Text.ToString().Length <= 0 || comboBox4.Text.ToString().Length <= 0 || comboBox5.Text.ToString().Length <= 0 || comboBox7.Text.ToString().Length <= 0 || comboBox9.Text.ToString().Length <= 0 || comboBox11.Text.ToString().Length <= 0 || comboBox13.Text.ToString().Length <= 0 || comboBox15.Text.ToString().Length <= 0)
            {
                MessageBox.Show("请先设置各类审批人和申请人");
            }
            else
            {
                try
                {
                    String   BID, Name, Invoice; //invoic 如果不为空  需要自动生成一个
                    String   pNmae;              //提供者公司 对应BuyId : provider
                    String   Ename;              //审批者   如果为空选择框中读取  对应BuyId 的person
                    String   Sub;                //总金额  对应BuyId SumMoney
                    String   BDate;              //购买日期   对应BuyId  OrderDate
                    DateTime Temp_BDate;         //转化的过度
                    String   PJID, BAPID, GDID;
                    String   sql1_1, sql1_2, sql1_3, sql5_1, sql4_1;
                    String   sql1, sql2, sql3, sql4, sql5, sql6;
                    String   OrderPerson, Person;
                    String   BIID, ID;
                    String   type, unit;
                    String   Num, CurrentNum; //买入数量和当前库存
                    String   Price;
                    String   PlanID;
                    DateTime PlanDate, GetDate, OrderDate, PlanGetDate, CheckDate; //入库日期是BDate  预计到货 PlanDate = BDate-3   GetDate = BDate-1   OrderDate =  BDate -7
                    DateTime EndDate;                                              //截止日期
                    DataGridViewCheckBoxCell checkCell;                            //PlanGetDate   计划到货时间
                    Boolean flag;
                    Random  r = new Random();
                    for (int row = 0; row <= this.dataGridView1.Rows.Count - 1; row++)
                    {
                        checkCell = (DataGridViewCheckBoxCell)dataGridView1.Rows[row].Cells[0];
                        flag      = Convert.ToBoolean(checkCell.Value);
                        if (flag == false)
                        {
                            continue;
                        }
                        ID          = this.dataGridView1["ID", row].Value.ToString();
                        BID         = this.dataGridView1["BID", row].Value.ToString();
                        Name        = this.dataGridView1["Name", row].Value.ToString();
                        Invoice     = this.dataGridView1["Invoice", row].Value.ToString();
                        pNmae       = this.dataGridView1["PName", row].Value.ToString();
                        Ename       = this.dataGridView1["Ename", row].Value.ToString();
                        Sub         = this.dataGridView1["Sub", row].Value.ToString();
                        BDate       = this.dataGridView1["BDate", row].Value.ToString();
                        Temp_BDate  = Convert.ToDateTime(BDate);  //强制转化
                        PJID        = this.dataGridView1["PJID", row].Value.ToString();
                        type        = this.dataGridView1["Type", row].Value.ToString();
                        unit        = this.dataGridView1["Unit", row].Value.ToString();
                        Num         = this.dataGridView1["Num", row].Value.ToString();
                        Price       = this.dataGridView1["Price", row].Value.ToString();
                        CurrentNum  = this.dataGridView1["CurrentNum", row].Value.ToString();
                        OrderPerson = comboBox3.Text.ToString();   //申请人
                        if (Ename.Length <= 0)
                        {
                            Person = comboBox4.Text.ToString();
                        }
                        else
                        {
                            Person = Ename;
                        }
                        if (Invoice.Length <= 0)
                        {
                            TimeSpan cha = (DateTime.Now - TimeZone.CurrentTimeZone.ToLocalTime(new System.DateTime(1970, 1, 1)));
                            long     t   = (long)cha.TotalSeconds; //用时间戳生成一个不会重复的表示符
                            Invoice = t.ToString();
                        }
                        if (Sub.Length <= 0)
                        {
                            Sub = "0";
                        }
                        if (CurrentNum.Length <= 0)
                        {
                            CurrentNum = "0";
                        }
                        PlanDate    = Temp_BDate.AddDays(-3);
                        OrderDate   = Temp_BDate.AddDays(-7);
                        GetDate     = Temp_BDate.AddDays(-1);
                        CheckDate   = PlanDate.AddDays(r.Next(0, 1)); //审核日期   0-1
                        PlanGetDate = PlanDate.AddDays(r.Next(2, 3)); //PlanGetDate     计划到货时间  PlanDate 0-3
                        //入库日期是BDate  预计到货 PlanDate = BDate-3   GetDate = BDate-1   OrderDate =  BDate -7
                        EndDate = OrderDate.AddDays(5);               //截止日期是申请日期+1
                        sql1_1  = @"INSERT INTO BuyPlan (PlanDate,Maker,Checker,CheckDate,State,IsInShopping,PlanType) 
                                 VALUES('" + PlanDate + "','" + comboBox5.Text.ToString() + "','" + comboBox7.Text.ToString() + "','" + CheckDate + "','1','3','1')";
                        SQLHelper db1_1 = new SQLHelper();
                        DataTable dt1_1 = db1_1.ExecuteDataTable(sql1_1);

                        sql1_2 = "select top(1) ID from BuyPlan  order by id desc";
                        SQLHelper db1_2 = new SQLHelper();
                        DataTable dt1_2 = db1_2.ExecuteDataTable(sql1_2);
                        PlanID = dt1_2.Rows[0][0].ToString();   //获取planID

                        sql1_3 = @"INSERT INTO BuyPlanDetail (BPID,Name,Type,Unit,MonthNeedAmount,PJDate,PJAmount,LowAmount,TopAmount,NeedAmount,PlanBuyAmount,PlanGetDate,BuyType,Remark,BuyAmount,toothcolor,pjid)
                                 VALUES('" + PlanID + "','" + Name + "','" + type + "','" + unit + "','0','" + PlanDate + "','" + CurrentNum + "','1','0','" + Num + "','" + Num + "','" + PlanGetDate + "','0','库存报警','" + Num + "','','" + PJID + "')";
                        SQLHelper db1_3 = new SQLHelper();
                        DataTable dt1_3 = db1_3.ExecuteDataTable(sql1_3);

                        sql1 = @"INSERT INTO BuyIn (Invoice,OrderPerson,Provider,Person,SumMoney,OrderDate,PlanID,Phone,Fax,Address,PayKind) VALUES 
                            ('" + Invoice + "','" + comboBox3.Text.ToString() + "','" + pNmae + "','" + comboBox4.Text.ToString() + "','" + Sub + "','" + OrderDate + "','" + PlanID + "','','','','')";
                        SQLHelper db = new SQLHelper();
                        DataTable dt = db.ExecuteDataTable(sql1);

                        sql2 = "select top(1) ID from BuyIn  order by id desc";
                        SQLHelper db2 = new SQLHelper();
                        DataTable dt2 = db2.ExecuteDataTable(sql2);
                        BIID = dt2.Rows[0][0].ToString();   //获取BII

                        sql3 = @"INSERT INTO BuyInDetail (BIID,BIName,BItype,BIUnit,BIAmount,Price,PlanDate,GetAmount,pjid,BIArea,Remark,toothcolor) 
                        VALUES ('" + BIID + "','" + Name + "','" + type + "','" + unit + "','" + Num + "','" + Price + "','" + PlanDate + "','" + Num + "','" + PJID + "','','','')";
                        SQLHelper db3 = new SQLHelper();
                        DataTable dt3 = db3.ExecuteDataTable(sql3);

                        sql4 = @"INSERT INTO BuyInGetDetail (BIID,Name,type,unit,Price,GetDate,GetAmount,BID,pjid,Area,Remark,toothcolor,State) VALUES 
                            ('" + BIID + "','" + Name + "','" + type + "','" + unit + "','" + Price + "','" + GetDate + "','" + Num + "','" + BID + "','" + PJID + "','','','','1')";
                        SQLHelper db4 = new SQLHelper();
                        DataTable dt4 = db4.ExecuteDataTable(sql4);

                        sql4_1 = "select top(1) ID from BuyInGetDetail  order by id desc";
                        SQLHelper db4_1 = new SQLHelper();
                        DataTable dt4_1 = db4_1.ExecuteDataTable(sql4_1);
                        GDID = dt4_1.Rows[0][0].ToString();   //获取GDID

                        sql5 = @"INSERT INTO BuyApplyPay(ApplyPerson,ApplyDate,Provider,Person,Bank,BankAccount,SumMoney,endPayDate,GetDate,verify1State,verify1,verify1Date,verify2State,verify2,verify2Date,IsPayed,PayMoney,Remark,PayDate,PayPerson)
                            VALUES('" + comboBox11.Text.ToString() + "','" + OrderDate + "','" + pNmae + "','','','','" + Sub + "','" + EndDate + "','','1','" + comboBox13.Text.ToString() + "','" + CheckDate + "','1','" + comboBox13.Text.ToString() + "','" + CheckDate + "','1','" + Sub + "','','" + CheckDate + "','" + comboBox15.Text.ToString() + "')";
                        SQLHelper db5 = new SQLHelper();
                        DataTable dt5 = db5.ExecuteDataTable(sql5);

                        sql5_1 = "select top(1) ID from BuyApplyPay  order by id desc";
                        SQLHelper db5_1 = new SQLHelper();
                        DataTable dt5_1 = db5_1.ExecuteDataTable(sql5_1);
                        BAPID = dt5_1.Rows[0][0].ToString();   //获取BAPID

                        sql6 = @"INSERT INTO BuyApplyPayDetail(BAPID,GDID,BIID,Name,type,Unit,Price,Area,GetDate,GetAmount,Remark)
                            VALUES('" + BAPID + "','" + GDID + "','" + BIID + "','" + Name + "','" + type + "','" + unit + "','" + Price + "','','" + GetDate + "','" + Num + "','')";
                        SQLHelper db6 = new SQLHelper();
                        DataTable dt6 = db6.ExecuteDataTable(sql6);

                        string newLine = "入库ID:" + ID + "已生成对应的采购记录和采购计划\n";
                        // 将textBox1的内容插入到第一行
                        // 索引0是 richText1 第一行位置
                        richTextBox1.Text = richTextBox1.Text.Insert(0, newLine);
                        richTextBox1.ScrollToCaret();
                    }
                    MessageBox.Show("生成完成");
                    GetGridView();
                }
                catch (Exception e3)
                {
                    WriteLog.Write_Log(e3);
                    MessageBox.Show(e3.Message);
                }
            }
        }
        public bool modifyDatePlan(string APIKey, string usernameTo, string usernameFrom, [FromBody] PlanDate planDate)
        {
            if (APIKey == this.APIKey)
            {
                User tempUser   = new User();
                int  userIDTo   = tempUser.getUserID(usernameTo);
                int  userIDFrom = tempUser.getUserID(usernameFrom);

                DBConnect  objDB  = new DBConnect();
                SqlCommand objCmd = new SqlCommand();
                objCmd.CommandType = CommandType.StoredProcedure;
                objCmd.CommandText = "TP_ModifyDatePlan";
                objCmd.Parameters.AddWithValue("@date", planDate.Date);
                objCmd.Parameters.AddWithValue("@time", planDate.Time);
                objCmd.Parameters.AddWithValue("@description", planDate.Description);
                objCmd.Parameters.AddWithValue("@requestFrom", userIDFrom);
                objCmd.Parameters.AddWithValue("@requestTo", userIDTo);

                int result = objDB.DoUpdateUsingCmdObj(objCmd);
                if (result == 1)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                return(false);
            }
        }
示例#8
0
 public Project(string name, PlanDate startdate)
 {
     Name      = name;
     Startdate = startdate;
 }