public ActionResult EditBtp(int id)
        {
            Repository <BTP> _repradbtn = new Repository <BTP>(AppConfig.DbConnexionString);
            BTP cour = _repradbtn.GetSingle(v => v.IdBtp == id, false);

            return(View(cour));
        }
        public ActionResult ajouterBtp(BTP tt)
        {
            Repository <BTP> _repradbtn = new Repository <BTP>(AppConfig.DbConnexionString);



            if (ModelState.IsValid)
            {
                _repradbtn.Add(tt);
                return(RedirectToAction("Index"));
            }
            return(View(tt));
        }
        public ActionResult EditBtp(BTP cour)
        {
            Repository <BTP> _repradbtn = new Repository <BTP>(AppConfig.DbConnexionString);

            if (ModelState.IsValid)
            {
                _repradbtn.Update(cour);

                return(RedirectToAction("Index"));
            }


            return(View(cour));
        }
        public ActionResult DeleteConfirmed4(int id)
        {
            int idcou = id;
            Repository <BTP> _reptoutabs1 = new Repository <BTP>(AppConfig.DbConnexionString);


            BTP cour = _reptoutabs1.GetSingle(v => v.IdBtp == idcou, false);

            _reptoutabs1.Delete(cour);



            return(RedirectToAction("Index"));
        }
        /// <summary>
        /// btp
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>



        public ActionResult DetailsBtp(int id)
        {
            int idcou = id;

            Repository <BTP> repadmin3 = new Repository <BTP>(AppConfig.DbConnexionString);
            BTP lis1 = repadmin3.GetSingle(v => v.IdBtp == idcou, false);

            if (lis1 == null)
            {
                return(HttpNotFound());
            }

            return(View(lis1));
        }
Example #6
0
        private void LoadBTP(String filename)
        {
            try
            {
                NitroFile file = Program.m_ROM.GetFileFromName(filename);
                m_BTP = new BTP(file);

                LoadOnlyBTPReferencedTextures();

                PopulateBTPListBoxes();

                EnableBTPFormControls();
            }
            catch (Exception ex) { MessageBox.Show("Error loading BTP:\n" + ex.Message + "\n" + ex.StackTrace); }
        }
        public ActionResult DeleteBtp(int id, bool?saveChangesError)
        {
            Repository <BTP> _reptoutabs1 = new Repository <BTP>(AppConfig.DbConnexionString);

            int idcou = id;


            if (saveChangesError.GetValueOrDefault())
            {
                ViewBag.ErrorMessage = "Unable to save changes. Try again, and if the problem persists see your system administrator.";
            }
            BTP cour = _reptoutabs1.GetSingle(v => v.IdBtp == idcou, false);

            return(View(cour));
        }
Example #8
0
 public static void InsertOrUpdate(BTP obj)
 {
     try
     {
         var db = new PMSEntities();
         if (obj.Id == 0)
         {
             obj.CreatedDate = DateTime.Now;
             db.BTPs.Add(obj);
             db.SaveChanges();
         }
     }
     catch (Exception)
     {
     }
 }
Example #9
0
        public int SuaThongTinOBJ(BTP obj)
        {
            int kq = -1;

            try
            {
                string sql = "update BTP set BTPNgay = '" + obj.BTPNgay + "', TimeUpdate = '" + obj.TimeUpdate + "' where Ngay ='" + obj.Ngay + "' and STTChuyen_SanPham ='" + obj.STTChuyen_SanPham + "' and STT=" + obj.STT + " and CumId=" + obj.CumId + " and CommandTypeId=" + obj.CommandTypeId;
                kq = dbclass.TruyVan_XuLy(sql);

                return(kq);
            }
            catch (Exception)
            {
                MessageBox.Show("Lỗi: Không thể thay đổi thông tin bán thành phẩm của chuyền dưới CSDL", "Lỗi truy vấn CSDL", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(kq);
            }
        }
Example #10
0
        public int ThemOBJ(BTP obj)
        {
            int kq = -1;

            try
            {
                string sql = "insert into BTP(Ngay, STTChuyen_SanPham, STT, BTPNgay, TimeUpdate, CumId, CommandTypeId, IsEndOfLine) values('" + obj.Ngay + "','" + obj.STTChuyen_SanPham + "', '" + obj.STT + "', '" + obj.BTPNgay + "', '" + obj.TimeUpdate + "', " + obj.CumId + ", " + obj.CommandTypeId + ", '" + obj.IsEndOfLine + "')";
                kq = dbclass.TruyVan_XuLy(sql);

                return(kq);
            }
            catch (Exception)
            {
                MessageBox.Show("Lỗi: Không thể lưu thông tin bán thành phẩm của chuyền vào CSDL", "Lỗi truy vấn CSDL", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(kq);
            }
        }
Example #11
0
        public List <BTP> GetListBTPBySTT(string sttChuyen_SanPham)
        {
            List <BTP> listBTP = null;

            try
            {
                dt.Clear();
                string sql = "select STT, BTPNgay, Ngay, IsEndOfLine, CommandTypeId, CumId from BTP where IsBTP_PB_HC = 0 and STTChuyen_SanPham = '" + sttChuyen_SanPham + "'";
                dt = dbclass.TruyVan_TraVe_DataTable(sql);
                if (dt != null && dt.Rows.Count > 0)
                {
                    listBTP = new List <BTP>();
                    foreach (DataRow row in dt.Rows)
                    {
                        BTP btp     = new BTP();
                        int btpNgay = 0;
                        int.TryParse(row["BTPNgay"].ToString(), out btpNgay);
                        btp.BTPNgay = btpNgay;
                        btp.Ngay    = row["Ngay"].ToString();
                        bool isEndOfLine = false;
                        bool.TryParse(row["IsEndOfLine"].ToString(), out isEndOfLine);
                        int commandTypeId = 0;
                        int.TryParse(row["CommandTypeId"].ToString(), out commandTypeId);
                        int clusterId = 0;
                        int.TryParse(row["CumId"].ToString(), out clusterId);
                        btp.CommandTypeId = commandTypeId;
                        btp.CumId         = clusterId;
                        btp.IsEndOfLine   = isEndOfLine;
                        listBTP.Add(btp);
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(listBTP);
        }
Example #12
0
        public bool MoveQuantityToMorthNow(int type)
        {
            bool result = false;

            try
            {
                BTPDAO                btpDAO            = new BTPDAO();
                ClusterDAO            clusterDAO        = new ClusterDAO();
                var                   ngay              = DateTime.Now.Day + "/" + DateTime.Now.Month + "/" + DateTime.Now.Year;
                var                   dateNow           = DateTime.Now;
                int                   morthNow          = dateNow.Month;
                int                   yearNow           = dateNow.Year;
                var                   dateOld           = dateNow.AddMonths(-1);
                int                   morthOld          = dateOld.Month;
                int                   yearOld           = dateOld.Year;
                string                strSQL            = "Select * From Chuyen_SanPham Where Thang=" + morthOld + " and Nam=" + yearOld + " and MaChuyen in (" + AccountSuccess.strListChuyenId.Trim() + ") and IsFinish=0 and IsDelete=0";
                List <Chuyen_SanPham> listChuyenSanPham = new List <Chuyen_SanPham>();
                DataTable             dtTable           = dbclass.TruyVan_TraVe_DataTable(strSQL);
                if (dtTable != null && dtTable.Rows.Count > 0)
                {
                    int sttThucHien = 1;
                    foreach (DataRow row in dtTable.Rows)
                    {
                        Chuyen_SanPham csp = new Chuyen_SanPham();
                        csp.STT = row["STT"].ToString();
                        int.TryParse(row["STTThucHien"].ToString(), out sttThucHien);
                        csp.STTThucHien = sttThucHien;
                        csp.MaChuyen    = row["MaChuyen"].ToString();
                        csp.MaSanPham   = row["MaSanPham"].ToString();
                        int sanLuongKH = 0;
                        int.TryParse(row["SanLuongKeHoach"].ToString(), out sanLuongKH);
                        csp.SanLuongKeHoach = sanLuongKH;
                        int luyKeTH = 0;
                        int.TryParse(row["LuyKeTH"].ToString(), out luyKeTH);
                        csp.LuyKeTH = luyKeTH;
                        float nangXuatSanXuat = 0;
                        float.TryParse(row["NangXuatSanXuat"].ToString(), out nangXuatSanXuat);
                        csp.NangXuatSanXuat = nangXuatSanXuat;
                        csp.Thang           = morthOld;
                        csp.Nam             = yearOld;
                        listChuyenSanPham.Add(csp);
                    }
                }
                if (listChuyenSanPham.Count > 0)
                {
                    listChuyenSanPham = listChuyenSanPham.OrderBy(c => c.STTThucHien).ToList();
                    int sttThucHien = 0;
                    foreach (var csp in listChuyenSanPham)
                    {
                        if (type == 1)
                        {
                            csp.IsFinish = 1;
                            csp.IsFinishBTPThoatChuyen = true;
                            //    SuaThongTinPhanCong(csp);
                        }
                        else
                        {
                            sttThucHien++;
                            int sumBTPOfLine = 0;
                            var listBTP      = btpDAO.GetListBTPBySTT(csp.STT);
                            if (listBTP != null && listBTP.Count > 0)
                            {
                                sumBTPOfLine = listBTP.Where(c => c.IsEndOfLine).Sum(c => c.BTPNgay);
                            }
                            var     listClusterOfLine = clusterDAO.GetCumOfChuyen(int.Parse(csp.MaChuyen));
                            Cluster clusterEndLine    = null;
                            if (listClusterOfLine != null && listClusterOfLine.Count > 0)
                            {
                                clusterEndLine = listClusterOfLine.First(c => c.IsEndOfLine);
                            }

                            if (csp.LuyKeTH == 0)
                            {
                                var cspNew = new Chuyen_SanPham();
                                Parse.CopyObject(csp, ref cspNew);
                                cspNew.TimeAdd = dateNow;
                                cspNew.Thang   = morthNow;
                                cspNew.Nam     = yearNow;
                                cspNew.IsMoveQuantityFromMorthOld = true;
                                cspNew.STTThucHien = sttThucHien;
                                // var resultAdd = ThemPhanCong(cspNew);
                                //if (resultAdd.IsSuccsess)
                                //{
                                //    csp.IsFinish = 1;
                                //    csp.IsFinishBTPThoatChuyen = true;
                                //    SuaThongTinPhanCong(csp);

                                //    string sttPCC = GetSTTChuyenSanPham(cspNew.MaChuyen, cspNew.MaSanPham, cspNew.Thang, cspNew.Nam);
                                //    if (sumBTPOfLine > 0)
                                //    {
                                //        BTP btp = new BTP();
                                //        btp.STTChuyen_SanPham = sttPCC;
                                //        btp.IsEndOfLine = true;
                                //        btp.Ngay = dateNow.Date;
                                //        btp.STT = 1;
                                //        btp.TimeUpdate = dateNow.TimeOfDay;
                                //        btp.BTPNgay = sumBTPOfLine;
                                //        btp.CommandTypeId = 8;
                                //        btp.CumId = clusterEndLine.Id;
                                //      btpDAO.ThemOBJ(btp);
                                //    }
                                //}
                            }
                            else
                            {
                                int soLuongTon = csp.SanLuongKeHoach - csp.LuyKeTH;
                                var cspExist   = CheckExistPCC(csp.MaChuyen, csp.MaSanPham, morthNow, yearNow);
                                if (cspExist != null)
                                {
                                    cspExist.SanLuongKeHoach += soLuongTon;
                                    var rsMove = SuaThongTinPhanCong(cspExist);
                                    if (rsMove > 0)
                                    {
                                        csp.SanLuongKeHoach        = csp.LuyKeTH;
                                        csp.IsFinish               = 1;
                                        csp.IsFinishBTPThoatChuyen = true;
                                        // SuaThongTinPhanCong(csp);

                                        int btpOnLine = sumBTPOfLine - csp.LuyKeTH;
                                        if (btpOnLine > 0)
                                        {
                                            BTP btp = new BTP();
                                            btp.STTChuyen_SanPham = cspExist.STT;
                                            btp.IsEndOfLine       = true;
                                            btp.Ngay          = ngay;
                                            btp.STT           = 1;
                                            btp.TimeUpdate    = dateNow.TimeOfDay;
                                            btp.BTPNgay       = btpOnLine;
                                            btp.CommandTypeId = 8;
                                            btp.CumId         = clusterEndLine.Id;
                                            //  btpDAO.ThemOBJ(btp);
                                        }
                                    }
                                }
                                else
                                {
                                    var cspNew = new Chuyen_SanPham();
                                    Parse.CopyObject(csp, ref cspNew);
                                    cspNew.TimeAdd                    = dateNow;
                                    cspNew.Thang                      = morthNow;
                                    cspNew.Nam                        = yearNow;
                                    cspNew.SanLuongKeHoach            = soLuongTon;
                                    cspNew.IsMoveQuantityFromMorthOld = true;
                                    cspNew.LuyKeTH                    = 0;
                                    csp.STTThucHien                   = sttThucHien;
                                    //var rsMove = ThemPhanCong(cspNew);
                                    //if (rsMove.IsSuccsess)
                                    //{
                                    //    csp.SanLuongKeHoach = csp.LuyKeTH;
                                    //    csp.IsFinish = 1;
                                    //    csp.IsFinishBTPThoatChuyen = true;
                                    //    SuaThongTinPhanCong(csp);

                                    //    string sttPCC = GetSTTChuyenSanPham(cspNew.MaChuyen, cspNew.MaSanPham, cspNew.Thang, cspNew.Nam);
                                    //    int btpOnLine = sumBTPOfLine - csp.LuyKeTH;
                                    //    if (btpOnLine > 0)
                                    //    {
                                    //        BTP btp = new BTP();
                                    //        btp.STTChuyen_SanPham = sttPCC;
                                    //        btp.IsEndOfLine = true;
                                    //        btp.Ngay = dateNow.Date;
                                    //        btp.STT = 1;
                                    //        btp.TimeUpdate = dateNow.TimeOfDay;
                                    //        btp.BTPNgay = btpOnLine;
                                    //        btp.CommandTypeId = 8;
                                    //        btp.CumId = clusterEndLine.Id;
                                    //        btpDAO.ThemOBJ(btp);
                                    //    }
                                    //}
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(result);
        }
Example #13
0
 public void button_to_continue()
 {
     BTP.ConfirmBattleTeam(CurrentTeamId);
 }