コード例 #1
0
        public static List <SaveExp> LoadSave()
        {
            string    query     = @"SELECT*FROM SAVEEXP";
            DataTable dataTable = new DataTable();//Can destroy.

            dataTable = DataProvider.QueryDataReader(query);
            SaveExp saveEx;

            if (dataTable != null && dataTable.Rows.Count > 0)
            {
                List <SaveExp> lstSaveExp = new List <SaveExp>();
                for (int i = 0; i < dataTable.Rows.Count; i++)
                {
                    saveEx                    = new SaveExp();
                    saveEx.ID                 = dataTable.Rows[i]["ID"].ToString();
                    saveEx.Ngay               = (string)dataTable.Rows[i]["NGAY"];
                    saveEx.Y                  = (int)dataTable.Rows[i]["Y"];
                    saveEx.Vt                 = float.Parse(dataTable.Rows[i]["VT"].ToString());
                    saveEx.ThoiGian           = float.Parse(dataTable.Rows[i]["THOIGIAN"].ToString());
                    saveEx.A                  = float.Parse(dataTable.Rows[i]["A"].ToString());
                    saveEx.BanKinh            = float.Parse(dataTable.Rows[i]["BANKINH"].ToString());
                    saveEx.KhoiLuongRiengVat  = float.Parse(dataTable.Rows[i]["KHOILUONGRIENGVAT"].ToString());
                    saveEx.KhoiLuongRiengChat = float.Parse(dataTable.Rows[i]["KHOILUONGRIENGCHAT"].ToString());
                    saveEx.X                  = (int)dataTable.Rows[i]["X"];
                    lstSaveExp.Add(saveEx);
                }
                return(lstSaveExp);
            }
            return(null);
        }
コード例 #2
0
        private void btn_Save_Click(object sender, EventArgs e)
        {
            try
            {
                idSave = int.Parse(SaveExp_DAL.quantityElement().Substring(3)) + 1;
                SaveExp newSaveEx = new SaveExp();
                newSaveEx.ID                 = IDS + idSave.ToString();
                newSaveEx.Ngay               = DateTime.Now.ToString();
                newSaveEx.Y                  = pbx_Object.Location.Y;
                newSaveEx.X                  = pbx_Object.Location.X;
                newSaveEx.Vt                 = float.Parse(khoicau.vt + "");
                newSaveEx.ThoiGian           = float.Parse(khoicau.time + "");
                newSaveEx.A                  = float.Parse(khoicau.a + "");
                newSaveEx.BanKinh            = float.Parse(khoicau.R + "");
                newSaveEx.KhoiLuongRiengVat  = float.Parse(khoiluongriengvat + "");
                newSaveEx.KhoiLuongRiengChat = float.Parse(khoiluongriengchatlong + "");

                bool result = SaveExp_BUL.InsertSave(newSaveEx);

                if (result)
                {
                    MessageBox.Show("Save success!", "Notice");
                }
                else
                {
                    MessageBox.Show("Fail", "Notice");
                }
            }
            catch (Exception ex)
            {
                Console.Write(ex.ToString());
                MessageBox.Show("Invalid dang an oshi!");
            }
        }
コード例 #3
0
        public static bool InsertSave(SaveExp saveExp)
        {
            /*Call method insert city into THANHPHO_DAL layer*/
            bool result = SaveExp_DAL.InsertSave(saveExp);

            return(result);
        }
コード例 #4
0
        public static bool InsertSave(SaveExp saveExp)
        {
            /*Set query.*/
            string query  = String.Format("INSERT INTO SAVEEXP (ID,NGAY,Y,VT,THOIGIAN,A,BANKINH,KHOILUONGRIENGVAT,KHOILUONGRIENGCHAT,X) VALUES ('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}')", saveExp.ID, saveExp.Ngay, saveExp.Y, saveExp.Vt, saveExp.ThoiGian, saveExp.A, saveExp.BanKinh, saveExp.KhoiLuongRiengVat, saveExp.KhoiLuongRiengChat, saveExp.X);
            bool   result = DataProvider.QueryExecuteNonQuery(query);/*Execute query in layer dataprovider.*/

            return(result);
        }
コード例 #5
0
        private SaveExp getInfor()
        {
            SaveExp infor = new SaveExp();

            infor.ID                 = dtgv_SaveExp.SelectedRows[0].Cells["ID"].Value.ToString();
            infor.Ngay               = dtgv_SaveExp.SelectedRows[0].Cells["NGAY"].Value.ToString();
            infor.Y                  = int.Parse(dtgv_SaveExp.SelectedRows[0].Cells["Y"].Value.ToString());
            infor.Vt                 = float.Parse(dtgv_SaveExp.SelectedRows[0].Cells["VT"].Value.ToString());
            infor.ThoiGian           = float.Parse(dtgv_SaveExp.SelectedRows[0].Cells["THOIGIAN"].Value.ToString());
            infor.A                  = float.Parse(dtgv_SaveExp.SelectedRows[0].Cells["A"].Value.ToString());
            infor.BanKinh            = float.Parse(dtgv_SaveExp.SelectedRows[0].Cells["BANKINH"].Value.ToString());
            infor.KhoiLuongRiengVat  = float.Parse(dtgv_SaveExp.SelectedRows[0].Cells["KHOILUONGRIENGVAT"].Value.ToString());
            infor.KhoiLuongRiengChat = float.Parse(dtgv_SaveExp.SelectedRows[0].Cells["KHOILUONGRIENGCHAT"].Value.ToString());
            infor.X                  = int.Parse(dtgv_SaveExp.SelectedRows[0].Cells["X"].Value.ToString());

            return(infor);
        }