Exemple #1
0
        public string getIDbyName(string projectName)
        {
            string projectID = "";
            string sql       = string.Format("SELECT projectID from Project where projectName = {1}", projectName);

            using (Dbconn) {
                MySqlCommand cmd = new MySqlCommand(sql);
                Dbconn.Open();
                cmd.Connection = Dbconn;
                using (var reader = cmd.ExecuteReader())
                {
                    if (reader.HasRows)
                    {
                        reader.Read();
                        projectID = reader.GetString(0);
                    }
                    else
                    {
                        projectID = UniqueIdFactory.RandomString(10);
                    }
                }
            }

            return(projectID);
        }
Exemple #2
0
        public int AddWork(string projectName, DateTime date, string type, DateTime beginTime,
                           DateTime endTime, string description, double priceBeforeTax, string paymentState)
        {
            ProjecRepository projecRepository = new ProjecRepository(ConnectionString);
            String           projectID        = projecRepository.getIDbyName(projectName);

            string sql = string.Format("INSERT INTO Work VALUES({0},{1},{2},{3},{4},{5},{6},{7},{8})",
                                       UniqueIdFactory.RandomString(10), //0 WorKid
                                       projectID,                        //1
                                       date,                             //2
                                       type,                             //3
                                       beginTime,                        //4
                                       endTime,                          //5
                                       description,                      //6
                                       priceBeforeTax,                   //7
                                       paymentState                      //8
                                       );

            using (Dbconn)
            {
                Dbconn.Open();
                MySqlCommand cmd = new MySqlCommand(sql);
                cmd.Connection = Dbconn;
                return(cmd.ExecuteNonQuery());
            }
        }
Exemple #3
0
 public Work(string projectID, DateTime date, DateTime beginTime, DateTime endTime, string description, double priceBeforeTax, string paymentState)
 {
     this.WorkID         = UniqueIdFactory.RandomString(10);
     this.ProjectID      = projectID;
     this.Date           = date;
     this.BeginTime      = beginTime;
     this.EndTime        = endTime;
     this.WorkingTime    = WorkingTime;
     this.PriceBeforeTax = priceBeforeTax;
     this.PaymentState   = paymentState;
 }