Ejemplo n.º 1
0
 public static bool delete(TheKho thekho)
 {
     try
     {
         using (EntitiesDataContext db = new EntitiesDataContext())
         {
             THEKHO tk;
             tk = (from t in db.THEKHOs
                   where t.masosach.Equals(thekho.MaSoSach) &&
                   t.ngayghi.Equals(thekho.NgayGhi)
                   select t).SingleOrDefault();
             if (tk == null)
             {
                 return(false);
             }
             db.THEKHOs.DeleteOnSubmit(tk);
             db.SubmitChanges();
             return(true);
         }
     }catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
         return(false);
     }
 }
Ejemplo n.º 2
0
 public static bool edit(TheKho thekho)
 {
     try
     {
         using (EntitiesDataContext db = new EntitiesDataContext())
         {
             THEKHO tk;
             tk = (from s in db.THEKHOs
                   where s.masosach.Equals(thekho.MaSoSach) &&
                   s.ngayghi.Equals(thekho.NgayGhi)
                   select s).SingleOrDefault();
             if (tk == null)
             {
                 return(false);            //Nếu không tồn tại thẻ kho
             }
             tk.soluong = thekho.SoLuong;
             db.SubmitChanges();
             return(true);
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
         return(false);
     }
 }
        public JsonResult GetPropertiesTonKho(string request)
        {
            List <string> results = new List <string>();

            foreach (string pro in TheKho.searchKeys())
            {
                results.Add(request + pro);
            }
            return(Json(results, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 4
0
        private void gr_btn_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
        {
            int    intRow       = gridView1.FocusedRowHandle;
            string strSanPhamID = string.Empty;

            if (intRow >= 0)
            {
                strSanPhamID = gridView1.GetRowCellValue(intRow, "SanPhamID").ToString();
            }
            if (strSanPhamID != string.Empty)
            {
                if (e.Button.Caption.ToUpper().Equals("THEKHO"))
                {
                    TheKho rpt = new TheKho();
                    rpt.SetDataSource(reportsController.prtTheKho(strSanPhamID));

                    frmViewReports fReport = new frmViewReports();
                    fReport.crystalReportViewer1.ReportSource = rpt;
                    fReport.MdiParent = this.MdiParent;
                    fReport.Show();
                }
            }
        }
Ejemplo n.º 5
0
 public static int add(TheKho thekho)
 {
     try
     {
         using (EntitiesDataContext db = new EntitiesDataContext())
         {
             THEKHO tk;
             tk = (from s in db.THEKHOs
                   where s.masosach.Equals(thekho.MaSoSach) &&
                   s.ngayghi.Equals(thekho.NgayGhi)
                   select s).SingleOrDefault();
             if (tk != null)
             {
                 tk.soluong = thekho.SoLuong;
                 db.SubmitChanges();
                 return(1);
             }
             else
             {
                 tk = new THEKHO()
                 {
                     masosach = thekho.MaSoSach,
                     soluong  = thekho.SoLuong,
                     ngayghi  = thekho.NgayGhi
                 };
                 db.THEKHOs.InsertOnSubmit(tk);
                 db.SubmitChanges();
                 return(1);
             }
         }
     }
     catch
     {
         return(0);
     }
 }