Beispiel #1
0
        public BranchesModel GetBranches()
        {
            var head = _repository.Head;

            if (head.Tip == null)
            {
                return(new BranchesModel());
            }

            var key          = CalcBranchesKey();
            var accessor     = GitCacheAccessor.Singleton(new HistoryDivergenceAccessor(_repoId, _repository, key));
            var aheadBehinds = accessor.Result.Value;
            var model        = new BranchesModel
            {
                Commit       = ToCommitModel(head.Tip, head.FriendlyName),
                AheadBehinds = aheadBehinds.Select(s => new AheadBehindModel
                {
                    Ahead  = s.Ahead,
                    Behind = s.Behind,
                    Commit = new CommitModel
                    {
                        ReferenceName = s.Name,
                        Author        = CreateSafeSignature(s.AuthorName, s.AuthorEmail, s.AuthorWhen),
                        Committer     = CreateSafeSignature(s.CommitterName, s.CommitterEmail, s.CommitterWhen),
                    },
                }).ToArray(),
            };

            return(model);
        }
        public async Task <JsonResult> UpdateBranches(BranchesModel model)
        {
            var Messaging = new RenderMessaging();

            try
            {
                if (User == null)
                {
                    Messaging.isError   = true;
                    Messaging.messaging = "Phiên đăng nhập đã hết hạn.";
                    return(Json(Messaging, JsonRequestBehavior.AllowGet));
                }

                if (string.IsNullOrEmpty(model.BranchesName) ||
                    string.IsNullOrEmpty(model.Address) ||
                    string.IsNullOrEmpty(model.Phone))
                {
                    Messaging.isError   = true;
                    Messaging.messaging = "Thông tin Kho không hợp lệ";
                    return(Json(Messaging, JsonRequestBehavior.AllowGet));
                }

                Messaging.isError = !await _IBrachesBusiness.UpdateBranches(model, User.UserId);

                Messaging.messaging = !Messaging.isError ? "Cập nhật kho thành công!" : "Cập nhật kho không thành công!";
            }
            catch (Exception ex)
            {
                Messaging.isError   = true;
                Messaging.messaging = "Cập nhật kho không thành công!";
            }
            return(Json(Messaging, JsonRequestBehavior.AllowGet));
        }
Beispiel #3
0
        public async Task <bool> UpdateBranches(BranchesModel model, int UserId)
        {
            if (model.BranchesId <= 0)
            {
                return(false);
            }

            var ob = unitOfWork.BrachesRepository.GetById(model.BranchesId);

            if (ob == null)
            {
                return(false);
            }


            ob.Code           = model.Code;
            ob.IsPrimary      = model.IsPrimary;
            ob.BranchesName   = model.BranchesName;
            ob.Phone          = model.Phone;
            ob.Address        = model.Address;
            ob.DateUpdate     = DateTime.Now;
            ob.EmployeeUpdate = UserId;

            unitOfWork.BrachesRepository.Update(ob, o => o.BranchesName,
                                                o => o.Code,
                                                o => o.IsPrimary,
                                                o => o.Phone, o => o.Address,
                                                o => o.DateUpdate, o => o.EmployeeUpdate);

            await unitOfWork.SaveChanges();

            return(true);
        }
Beispiel #4
0
        }// end of function

        public BranchesModel GetLastNO(BranchesModel _refmodel, string _Brstn)
        {
            DBConnect();
            string sql = "SELECT  DateEncoded,BRSTN,Address1,LastNo_C,LastNo_CS,LastNo_P FROM " + databaseName + ".banko_nuestra_branches where BRSTN ='" + _Brstn + "'";

            MySqlCommand cmd = new MySqlCommand(sql, myConnect);

            MySqlDataReader myReader = cmd.ExecuteReader();


            while (myReader.Read())
            {
                // _refmodel.ID = int.Parse(myReader.GetString(0));
                _refmodel.Date      = DateTime.Parse(myReader.GetString(0));
                _refmodel.BRSTN     = myReader.GetString(1);
                _refmodel.Address1  = myReader.GetString(2);
                _refmodel.LastNo_C  = myReader.GetInt64(3);
                _refmodel.LastNo_CS = myReader.GetInt64(4);
                _refmodel.LastNo_P  = myReader.GetInt64(5);
                //_refmodel.C_Before = int.Parse(myReader.GetString(7));
            }

            DBClosed();
            return(_refmodel);
        }// end of function
        public async Task <JsonResult> RemoveBranchs(BranchesModel model)
        {
            var Messaging = new RenderMessaging();

            try
            {
                if (User == null)
                {
                    Messaging.isError   = true;
                    Messaging.messaging = "Phiên đăng nhập đã hết hạn.";
                    return(Json(Messaging, JsonRequestBehavior.AllowGet));
                }
                if (model.BranchesId <= 0)
                {
                    Messaging.isError   = true;
                    Messaging.messaging = "Thông tin Kho không hợp lệ";
                    return(Json(Messaging, JsonRequestBehavior.AllowGet));
                }

                Messaging.isError = !await _IBrachesBusiness.RemoveBranchs(model.BranchesId);

                Messaging.messaging = Messaging.isError ? "Kho không xóa được vui lòng kiểm tra lại." : "Xóa Kho thành công!";

                return(Json(Messaging, JsonRequestBehavior.AllowGet));
            }
            catch
            {
                Messaging.isError   = true;
                Messaging.messaging = "Kho không xóa được vui lòng kiểm tra lại.";
            }
            return(Json(Messaging, JsonRequestBehavior.AllowGet));
        }
Beispiel #6
0
        public ActionResult Edit(BranchesModel modifiedModel, string FILTER_Keyword, int?FILTER_Active)
        {
            if (ModelState.IsValid)
            {
                if (isExists(modifiedModel.Id, modifiedModel.Name))
                {
                    ModelState.AddModelError(BranchesModel.COL_Name.Name, $"{modifiedModel.Name} sudah terdaftar");
                }
                else
                {
                    BranchesModel originalModel = db.Branches.AsNoTracking().Where(x => x.Id == modifiedModel.Id).FirstOrDefault();

                    string log = string.Empty;
                    log = Helper.append(log, originalModel.Name, modifiedModel.Name, BranchesModel.COL_Name.LogDisplay);
                    log = Helper.append(log, originalModel.Address, modifiedModel.Address, BranchesModel.COL_Address.LogDisplay);
                    log = Helper.append(log, originalModel.PhoneNumber, modifiedModel.PhoneNumber, BranchesModel.COL_PhoneNumber.LogDisplay);
                    log = Helper.append(log, originalModel.Notes, modifiedModel.Notes, BranchesModel.COL_Notes.LogDisplay);
                    log = Helper.append(log, originalModel.InvoiceHeaderText, modifiedModel.InvoiceHeaderText, BranchesModel.COL_InvoiceHeaderText.LogDisplay);
                    log = Helper.append(log, originalModel.Active, modifiedModel.Active, BranchesModel.COL_Active.LogDisplay);

                    if (!string.IsNullOrEmpty(log))
                    {
                        db.Entry(modifiedModel).State = EntityState.Modified;
                        ActivityLogsController.AddEditLog(db, Session, modifiedModel.Id, log);
                        db.SaveChanges();
                    }

                    return(RedirectToAction(nameof(Index), new { FILTER_Keyword = FILTER_Keyword, FILTER_Active = FILTER_Active }));
                }
            }

            setViewBag(FILTER_Keyword, FILTER_Active);
            return(View(modifiedModel));
        }
Beispiel #7
0
        public BranchesModel GetBranches()
        {
            var head = _repository.Head;

            if (head.Tip == null)
            {
                return(new BranchesModel());
            }

            var sha          = CalcBranchesSha();
            var aheadBehinds = GitCache.Get <RevisionSummaryCacheItem[]>(sha, "branches");

            if (aheadBehinds == null)
            {
                aheadBehinds = _repository.Branches
                               .Where(s => s != head && s.Name != "HEAD")
                               .OrderByDescending(s => s.Tip.Author.When)
                               .Select(branch =>
                {
                    var commit     = branch.Tip;
                    var divergence = _repository.ObjectDatabase.CalculateHistoryDivergence(commit, head.Tip);
                    return(new RevisionSummaryCacheItem
                    {
                        Ahead = divergence.AheadBy ?? 0,
                        Behind = divergence.BehindBy ?? 0,
                        Name = branch.Name,
                        Sha = commit.Sha,
                        AuthorName = commit.Author.Name,
                        AuthorEmail = commit.Author.Email,
                        AuthorWhen = commit.Author.When,
                        CommitterName = commit.Committer.Name,
                        CommitterEmail = commit.Committer.Email,
                        CommitterWhen = commit.Committer.When,
                    });
                })
                               .ToArray();
                GitCache.Set(sha, "branches", aheadBehinds);
            }
            var model = new BranchesModel
            {
                Commit       = ToCommitModel(head.Tip, head.Name),
                AheadBehinds = aheadBehinds.Select(s => new AheadBehindModel
                {
                    Ahead  = s.Ahead,
                    Behind = s.Behind,
                    Commit = new CommitModel
                    {
                        ReferenceName = s.Name,
                        Author        = new Signature(s.AuthorName, s.AuthorEmail, s.AuthorWhen),
                        Committer     = new Signature(s.CommitterName, s.CommitterEmail, s.CommitterWhen),
                    },
                }).ToArray(),
            };

            return(model);
        }
Beispiel #8
0
        }// end of function

        public BranchesModel UpdateRef(BranchesModel _ref, string _brstn)
        {
            DBConnect();
            string       sql = "Update " + databaseName + ".banko_nuestra_branches SET LastNo_C = '" + _ref.LastNo_C + "',LastNo_CS = '" + _ref.LastNo_CS + "' ,LastNo_P = '" + _ref.LastNo_P + "', DateUpdated = '" + _ref.DateUpdated.ToString("yyyy-MM-dd") + "' where BRSTN = '" + _brstn + "'";
            MySqlCommand cmd = new MySqlCommand(sql, myConnect);

            MySqlDataReader myReader = cmd.ExecuteReader();

            DBClosed();
            return(_ref);
        }// end of function
Beispiel #9
0
        private void Hapus_Click(object sender, EventArgs e)
        {
            DialogResult dialog = MessageBox.Show("Yakin ?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);

            if (dialog == DialogResult.Yes)
            {
                BranchesModel branch = (BranchesModel)BranchBS.Current;
                BranchXpCollection.Remove(branch);
                branch.Delete();
                BranchUOW.CommitChanges();
            }
        }
Beispiel #10
0
        private void Simpan_Click(object sender, EventArgs e)
        {
            if (!validator.Validate())
            {
                return;
            }

            BranchesModel branch = (BranchesModel)BranchBS.Current;

            branch.Save();
            BranchXpCollection.Add(branch);
            BranchUOW.CommitChanges();
            BranchBS.EndEdit();

            ViewState();
        }
Beispiel #11
0
        public async Task <bool> CreateBranches(BranchesModel model, int UserId)
        {
            var objBraches = Mapper.Map <soft_Branches>(model);

            objBraches.DateCreate = DateTime.Now;

            objBraches.EmployeeCreate = UserId;

            objBraches.Type = 1;

            unitOfWork.BrachesRepository.Add(objBraches);

            await unitOfWork.SaveChanges();

            return(true);
        }
Beispiel #12
0
        public BranchesModel GetBrstn(BranchesModel _refmodel, string _branch)
        {
            DBConnect();
            string          sql      = "Select brstn from " + databaseName + ".banko_nuestra_branches where Address1 = '" + _branch + "'";
            MySqlCommand    cmd      = new MySqlCommand(sql, myConnect);
            MySqlDataReader myReader = cmd.ExecuteReader();

            while (myReader.Read())
            {
                _refmodel.BRSTN = myReader.GetString(0);
            }

            DBClosed();

            return(_refmodel);
        }
Beispiel #13
0
        private void cmbBranch_SelectedIndexChanged(object sender, EventArgs e)
        {
            //  DataTable dt = new DataTable();
            BranchesModel brmodel = new BranchesModel();

            if (cmbBranch.Text == "SAN SIMON PAMPANGA BRANCH")
            {
                db.GetBrstn(brmodel, cmbBranch.Text);

                txtBrstn.Text = brmodel.BRSTN.ToString();
                cheque.BRSTN  = txtBrstn.Text;
                db.GetLastNO(br, cheque.BRSTN);
                LastNoP = int.Parse(br.LastNo_P.ToString());
                LastNoC = int.Parse(br.LastNo_C.ToString());
            }
        }
Beispiel #14
0
        public ActionResult Create(BranchesModel model, string FILTER_Keyword, int?FILTER_Active)
        {
            if (ModelState.IsValid)
            {
                if (isExists(null, model.Name))
                {
                    ModelState.AddModelError(BranchesModel.COL_Name.Name, $"{model.Name} sudah terdaftar");
                }
                else
                {
                    model.Id     = Guid.NewGuid();
                    model.Active = true;
                    db.Branches.Add(model);
                    ActivityLogsController.AddCreateLog(db, Session, model.Id);
                    db.SaveChanges();
                    return(RedirectToAction(nameof(Index), new { id = model.Id, FILTER_Keyword = FILTER_Keyword, FILTER_Active = FILTER_Active }));
                }
            }

            setViewBag(FILTER_Keyword, FILTER_Active);
            return(View(model));
        }
Beispiel #15
0
        }//end of function

        public BranchesModel GetBranchesDetails(BranchesModel _refmodel, string _Brstn)
        {
            DBConnect();
            string sql = "SELECT BRSTN,Address1, Address2, Address3,Address4,Address5,Address6 FROM captive_database.isla_branches where BRSTN ='" + _Brstn + "'";

            MySqlCommand cmd = new MySqlCommand(sql, myConnect);

            MySqlDataReader myReader = cmd.ExecuteReader();

            while (myReader.Read())
            {
                _refmodel.BRSTN    = myReader.GetString(0);
                _refmodel.Address1 = myReader.GetString(1);
                _refmodel.Address2 = myReader.GetString(2);
                _refmodel.Address3 = myReader.GetString(3);
                _refmodel.Address4 = myReader.GetString(4);
                _refmodel.Address5 = myReader.GetString(5);
                _refmodel.Address6 = myReader.GetString(6);
            }

            DBClosed();
            return(_refmodel);
        }// end of function
 public string ConvertBranches(BranchesModel data)
 {
     return("Branchname is: " + data.branchname + ", ID is: " + data.id + ", description is: " + data.description + ", created at"
            + data.created_date + ", ID of creator: " + data.creator_id + "\\n");
 }
Beispiel #17
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            DatabaseConnectionsServices dbconnection = new DatabaseConnectionsServices();

            if (deliveryDate == dateTime)
            {
                MessageBox.Show("Please set the delivery date!!!");
            }
            else
            {
                DialogResult  result1 = MessageBox.Show("", "Do you to saved this record?", MessageBoxButtons.YesNo);
                BranchesModel branch  = new BranchesModel();


                if (result1.ToString() == "Yes")
                {
                    CheckBRSTNandChkType();
                    qty = int.Parse(txtOrQty.Text);

                    _checkModel.AccountNo = txtAccountNumber.Text;
                    _checkModel.Address1  = cmbBranch.Text;
                    _checkModel.ChkType   = _ChkType;
                    if (_checkModel.ChkType == "MC")
                    {
                        _checkModel.ChkTypeName = "MANAGERS CHECK";
                    }
                    else if (_checkModel.ChkType == "MC_CONT")
                    {
                        _checkModel.ChkTypeName = "MANAGERS CHECK CONTINUES";
                    }
                    else
                    {
                        _checkModel.ChkTypeName = cmbChkType.Text;
                    }

                    _checkModel.Name1 = txtAccountName1.Text;
                    _checkModel.Name2 = txtAccountName2.Text;

                    _checkModel.BRSTN = _Brstn;

                    _checkModel.BranchName = cmbBranch.Text;
                    _checkModel.Address1   = cmbBranch.Text;
                    dbconnection.GetBranchesDetails(branch, _checkModel.BRSTN);
                    if (branch != null)
                    {
                        _checkModel.Address2 = branch.Address2.ToString();
                        _checkModel.Address3 = branch.Address3.ToString();
                        _checkModel.Address4 = branch.Address4.ToString();
                        _checkModel.Address5 = branch.Address5.ToString();
                        _checkModel.Address6 = branch.Address6.ToString();
                    }

                    _checkModel.Qty = qty;

                    deliveryDate             = dateTimePicker1.Value;
                    _checkModel.DeliveryDate = deliveryDate;
                    if (_checkModel != null)
                    {
                        for (int i = 0; i < qty; i++)
                        {
                            dbconnection.GetLastNO(refMode, _checkModel.ChkType, _checkModel.BRSTN);


                            Int64  s      = refMode.LastNo + 1;
                            string lastNo = refMode.LastNo.ToString();

                            int endRefno = int.Parse(lastNo);

                            _checkModel.StartSeries = s.ToString();

                            if (_checkModel.ChkType == "A" || _checkModel.ChkType == "MC" || _checkModel.ChkType == "MC_CONT" || _checkModel.ChkType == "SR" || _checkModel.ChkType == "TD")
                            {
                                endRefno = endRefno + bookperpcs;
                            }
                            else if (_checkModel.ChkType == "B")
                            {
                                endRefno = endRefno + bookperpcs;
                            }

                            _checkModel.EndSeries = endRefno.ToString();
                            refMode.Date          = dateTime;
                            refMode.LastNo        = endRefno;

                            dbconnection.SaveToSecondaryTable(_checkModel);
                            // dbconnection.UpdateRef(refMode);


                            string _brstn   = _checkModel.BRSTN.ToString();
                            string _chktype = _checkModel.ChkType.ToString();
                        }

                        MessageBox.Show("Data has been Saved!");

                        dbconnection.UpdateRef(refMode);

                        CheckLoadData();
                    }



                    //   MessageBox.Show(_checkModel.DeliveryDate.ToString() + dateTime.ToString());
                    ClearAllInputText();
                }
                else
                {
                    MessageBox.Show("Saving Cancelled!!!!");
                }
            }
        }