Пример #1
0
        public ActionResult UploadHSFile(IEnumerable <HttpPostedFileBase> fileInput)
        {
            string failParts = string.Empty;

            try
            {
                HttpPostedFileBase fb         = Request.Files[0];
                string             tempGuid   = Guid.NewGuid().ToString();
                string             folderPath = Server.MapPath(CHubConstValues.ChubTempFolder);
                FileInfo           folder     = new FileInfo(folderPath);
                if (!Directory.Exists(folder.FullName))
                {
                    Directory.CreateDirectory(folder.FullName);
                }

                string fileFullName = folder.FullName + tempGuid + ".xlsx";
                fb.SaveAs(fileFullName);

                NPOIExcelHelper excelHelper = new NPOIExcelHelper(fileFullName);
                DataTable       dt          = excelHelper.ExcelToDataTable();
                //Delete temp file
                System.IO.File.Delete(fileFullName);

                if (dt == null || dt.Rows.Count == 0)
                {
                    return(Content("No data in excel"));
                }

                //DataTable dt = ExcelHelper.GetDTFromExcel(fileFullName);
                List <TC_PART_HS> partList = ClassConvert.ConvertDT2List <TC_PART_HS>(dt);

                if (partList == null || partList.Count == 0)
                {
                    return(Content("wrong excel strut"));
                }

                int successCount = 0;
                int failCount    = 0;

                foreach (var item in partList)
                {
                    if (SaveTCPartData(item, null))
                    {
                        successCount++;
                    }
                    else
                    {
                        failCount++;
                        failParts += (item.PART_NO + "|");
                    }
                }
                //foreach add try catch region
                string msg = string.Format("Total Count:{0}, Success Count:{1}, Fail Count:{2} :{3}", partList.Count, successCount, failCount, failParts);
                return(Json(new RequestResult(true, msg)));
            }
            catch (Exception ex)
            {
                return(Json(new RequestResult(false, ex.Message)));
            }
        }
Пример #2
0
 private void tbKeyWorlds_TextChanged(object sender, EventArgs e)
 {
     if (currentPhotograph != null)
     {
         currentPhotograph.KeyWords = ClassConvert.getKeysList(tbKeyWorlds.Text);
     }
 }
Пример #3
0
        private void button1_Click(object sender, EventArgs e)
        {
            List <int> list        = ClassConvert.StrToList <int>(InputListtextBox1.Text);
            ClassList  changedlist = new ClassList(list);
            List <int> newlist     = changedlist.Process();

            OutputListlabel.Text = ClassConvert.ListToStr(newlist, " ");
        }
Пример #4
0
        private void button1_Click(object sender, EventArgs e)
        {
            int[]    arr    = ClassConvert.StrToArray <int>(textBox1.Text);
            ClassArr arrSum = new ClassArr(arr);

            string answer = arrSum.Sum().ToString();

            label2.Text = answer;
        }
Пример #5
0
        public ExVAliasAddr GetSpecifyAliasAddrDFLT(string aliasName, string sysID, string cusNo, decimal bill2Location, decimal ship2Location)
        {
            V_ALIAS_ADDR_DFLT addrDFLT = dal.GetSpecifyAliasAddrDFLT(aliasName, sysID, cusNo, (int)bill2Location, (int)ship2Location);
            ClassConvertTable cct      = new ClassConvertTable();
            ExVAliasAddr      ex       = new ExVAliasAddr();

            ClassConvert.ConvertAction(addrDFLT, ex, cct.AliasAddrDFLTConvert);
            return(ex);
        }
Пример #6
0
        private void button1_Click(object sender, EventArgs e)
        {
            int[]    arr          = ClassConvert.StrToArray <int>(ArrTextBox.Text);
            ClassArr arrNegNumber = new ClassArr(arr);

            string answer = arrNegNumber.NegativeNumber().ToString();

            label2.Text = answer;
        }
Пример #7
0
        public ExVAliasAddr GetSpecifyAliasAddrSPL(string aliasName, string sysID, string cusNo, decimal bill2Location, decimal ship2Location, decimal destLocation)
        {
            V_ALIAS_ADDR_SPL  addrSPL = dal.GetSpecifyAliasAddrSPL(aliasName, sysID, cusNo, (int)bill2Location, (long)ship2Location, (long)destLocation);
            ClassConvertTable cct     = new ClassConvertTable();
            ExVAliasAddr      ex      = new ExVAliasAddr();

            ClassConvert.ConvertAction(addrSPL, ex, cct.AliasAddrSPLConvert);
            return(ex);
        }
Пример #8
0
 private void buttonAdd_Click(object sender, EventArgs e)
 {
     photograph             = new Photograph();
     photograph.Name        = tbName.Text;
     photograph.Category    = cbCategory.Text;
     photograph.Description = tbDescription.Text;
     photograph.KeyWords    = ClassConvert.getKeysList(tbKeyWorlds.Text);
     photograph.Photo       = ClassConvert.ConvertImageToBase64(tbPhotoFile.Text);
     this.DialogResult      = DialogResult.OK;
 }
Пример #9
0
        public bool SaveTCPartData(TC_PART_HS partHS, M_PART mPart)
        {
            using (CHubEntities db = new CHubEntities())
            {
                M_PART_BLL mPartBLL = new M_PART_BLL();
                if (mPartBLL.Exist(partHS.PART_NO))
                {
                    //must exist in m_part otherwise error
                    if (mPart != null && !string.IsNullOrEmpty(mPart.TC_CATEGORY_BY_MAN))
                    {
                        M_PART currMpart = mPartBLL.GetMPartByPartNo(partHS.PART_NO);
                        currMpart.TC_CATEGORY_BY_MAN = mPart.TC_CATEGORY_BY_MAN;
                        mPartBLL.Update(currMpart);
                    }
                    if (partHS != null)
                    {
                        TC_PART_HS_BLL pHSBLL = new TC_PART_HS_BLL(db);
                        if (pHSBLL.Exist(partHS.PART_NO))
                        {
                            //update
                            TC_PART_HS    existModel = pHSBLL.GetTCPartHS(partHS.PART_NO);
                            List <string> skipList   = new List <string>();
                            skipList.Add("PART_NO");
                            skipList.Add("CREATED_BY");
                            skipList.Add("CREATE_DATE");
                            skipList.Add("UPDATED_BY");
                            skipList.Add("RECORD_DATE");

                            ClassConvert.DrawObj(partHS, existModel, skipList);

                            existModel.UPDATED_BY  = Session[CHubConstValues.SessionUser].ToString();
                            existModel.RECORD_DATE = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd"));
                            pHSBLL.update(existModel, false);
                        }
                        else
                        {
                            //add
                            partHS.CREATED_BY  = Session[CHubConstValues.SessionUser].ToString();
                            partHS.CREATE_DATE = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd"));
                            partHS.UPDATED_BY  = Session[CHubConstValues.SessionUser].ToString();
                            partHS.RECORD_DATE = partHS.CREATE_DATE;
                            pHSBLL.Add(partHS, false);
                        }
                    }
                    db.SaveChanges();
                    return(true);
                }
                else
                {
                    //error part
                    LogHelper.WriteErrorLog(string.Format("Fail Save Action, reason: Wrong partNo {0}", partHS.PART_NO));
                    return(false);
                }
            }
        }
Пример #10
0
        static async Task Main(string[] args)
        {
            Console.WriteLine("=================    Fixed Memory Examples ======================");
            FixedKeywordExamples.Examples();

            Console.WriteLine("=================    Conversion Examples   ======================");
            ClassConvert.Conversions();

            Console.WriteLine("===================   Function pointers   =======================");
            FunctionPointers.PointerExamples();
        }
Пример #11
0
        private void treeViewPhoto_AfterSelect(object sender, TreeViewEventArgs e)
        {
            if (e.Node.Level == 1)
            {
                setVisible(true);
                currentPhotograph = Photos.Photographs.Where(p => p.Name == e.Node.Name && p.Category == e.Node.Parent.Name).First();

                pictureBoxPhoto.Image = ClassConvert.ConvertBase64ToImage(currentPhotograph.Photo);
                tbKeyWorlds.Text      = ClassConvert.getKeyString(currentPhotograph.KeyWords);
                rtbDescription.Text   = currentPhotograph.Description;
            }
        }
Пример #12
0
        // POST: /BasicDataManagement/Department/Delete/
        public ActionResult Delete()
        {
            Department[] datas = ClassConvert <Department> .Process(Request.Form);

            foreach (var data in datas)
            {
                var result = _departmentService.Delete(data);
                if (result.ResultType != OperationResultType.Success)
                {
                    return(Json(new { error = result.ResultType.GetDescription(), total = datas.Length, data = datas }));
                }
            }
            return(Json(new { total = datas.Length, data = datas }, JsonRequestBehavior.AllowGet));
        }
Пример #13
0
        public List <ExVAliasAddr> GetStrictAliasAddrDFLT(string shipName, string addr, string aliasName)
        {
            List <V_ALIAS_ADDR_DFLT> list   = dal.GetStrictAliasAddrDFLT(shipName, addr, aliasName);
            List <ExVAliasAddr>      exList = new List <ExVAliasAddr>();

            ClassConvertTable cct = new ClassConvertTable();

            foreach (var item in list)
            {
                ExVAliasAddr ex = new ExVAliasAddr();
                ClassConvert.ConvertAction(item, ex, cct.AliasAddrDFLTConvert);
                exList.Add(ex);
            }

            return(exList);
        }
Пример #14
0
        private void resultbutton_Click(object sender, EventArgs e)
        {
            try
            {
                List <Line> lines = LineDGVConvert.DGVToLineList(InputLineDGV);

                ClassList  line    = new ClassList(lines);
                List <int> newlist = line.Result();

                OutputListlabel.Text = ClassConvert.ListToStr(newlist, " ");
            }
            catch (Exception ex)
            {
                MessagesUtils.ShowError("Произошла ошибка!");
            }
        }
Пример #15
0
        public ActionResult EditPersonal()
        {
            PersonalRecord[] datas = ClassConvert <PersonalRecord> .Process(Request.Form);

            foreach (var data in datas)
            {
                var result = _personalRecordService.Update(data, true);
                result.Message = result.Message ?? result.ResultType.GetDescription();
                if (result.ResultType != OperationResultType.Success)
                {
                    return(Json(new { error = result.Message, total = datas.Length, data = datas }));
                }
            }

            return(Json(new { total = datas.Length, data = datas }, JsonRequestBehavior.AllowGet));
        }
Пример #16
0
        // POST: /App/ApplyForm/DeletePersonal/
        public ActionResult DeletePersonal()
        {
            //List<string> serialNumberList = new List<string>();
            List <PersonalRecord> list = new List <PersonalRecord>();

            PersonalRecord[] datas = ClassConvert <PersonalRecord> .Process(Request.Form);

            foreach (var data in datas)
            {
                //serialNumberList.Add(data.SerialNumber);
                list.Add(data);
            }
            // _personalRecordService.Delete(serialNumberList, true);
            _personalRecordService.DeleteModel(list, true);
            return(Json(new { total = datas.Length, data = datas }, JsonRequestBehavior.AllowGet));
        }
Пример #17
0
        public List <ExVAliasAddr> GetAliasAddrSPL(string localDestName, string addr, string destName, long?destLocation, string aliasName)
        {
            List <V_ALIAS_ADDR_SPL> list   = dal.GetAliasAddrSPL(localDestName, addr, destName, destLocation, aliasName);
            List <ExVAliasAddr>     exList = new List <ExVAliasAddr>();

            ClassConvertTable cct = new ClassConvertTable();

            foreach (var item in list)
            {
                ExVAliasAddr ex = new ExVAliasAddr();
                ClassConvert.ConvertAction(item, ex, cct.AliasAddrSPLConvert);
                exList.Add(ex);
            }

            return(exList);
        }
Пример #18
0
        public ActionResult Create()
        {
            DepartmentVM[] datas = ClassConvert <DepartmentVM> .Process(Request.Form);

            var result = _departmentService.Insert(datas[0]);

            if (result.ResultType != OperationResultType.Success)
            {
                return(Json(new { error = result.ResultType.GetDescription(), total = 1, data = this._departmentService.Departments.ToArray() }));
            }
            else
            {
                Department[] results = this._departmentService.Departments.ToArray();
                return(Json(new { total = 1, data = new[] { results[results.Length - 1] } }));
            }
        }
Пример #19
0
        public ActionResult Create()
        {
            TaxBaseEveryMonthVM[] datas = ClassConvert <TaxBaseEveryMonthVM> .Process(Request.Form);

            var result = _taxBaseEveryMonthService.Insert(datas[0]);

            if (result.ResultType != OperationResultType.Success)
            {
                return(Json(new { error = result.ResultType.GetDescription(), total = 1, data = this._taxBaseEveryMonthService.TaxBaseEveryMonths.ToArray() }));
            }
            else
            {
                TaxBaseEveryMonth[] results = this._taxBaseEveryMonthService.TaxBaseEveryMonths.ToArray();
                return(Json(new { total = 1, data = new[] { results[results.Length - 1] } }));
            }
        }
Пример #20
0
        public ActionResult Edit()
        {
            AuditOpinion[] datas = ClassConvert <AuditOpinion> .Process(Request.Form);

            foreach (var data in datas)
            {
                var result = _auditOpinionService.Update(data);
                result.Message = result.Message ?? result.ResultType.GetDescription();
                if (result.ResultType != OperationResultType.Success)
                {
                    return(Json(new { error = result.ResultType.GetDescription(), total = datas.Length, data = datas }));
                }
            }

            return(Json(new { total = datas.Length, data = datas }, JsonRequestBehavior.AllowGet));
        }
Пример #21
0
        public void ConvertTest()
        {
            ModelClass model = new ModelClass()
            {
                id         = "234234234sdfsdfsdfsdfsdfsdf",
                number     = "23",
                Name       = "allen",
                IsRight    = "true",
                IsWrong    = "false",
                Date       = "2017-09-09",
                CreateDate = "2017-12-12",
                childs     = new List <ModelClassChild>()
                {
                    new ModelClassChild()
                    {
                        id        = "1111",
                        childname = "child1"
                    },
                    new ModelClassChild()
                    {
                        id        = "2222",
                        childname = "child2"
                    }
                }
            };

            var convertSuccess = true;

            try
            {
                EntityClass entity = new EntityClass();
                entity = ClassConvert.Convert <ModelClass, EntityClass>(model);


                ModelClass cM = ClassConvert.Convert <EntityClass, ModelClass>(entity);

                var aa = true;
            }
            catch (Exception e)
            {
                convertSuccess = false;
            }


            Assert.IsTrue(convertSuccess);
        }
Пример #22
0
        // POST: /App/TopContacts/Delete/
        public ActionResult Delete()
        {
            string userid = ((System.Web.Security.FormsIdentity)(System.Web.HttpContext.Current.User.Identity)).Ticket.UserData;

            TopContacts[] datas = ClassConvert <TopContacts> .Process(Request.Form);

            foreach (var data in datas)
            {
                data.UserID = userid;
                var result = _topContactsService.Delete(data);
                if (result.ResultType != OperationResultType.Success)
                {
                    return(Json(new { error = result.ResultType.GetDescription(), total = datas.Length, data = datas }));
                }
            }
            return(Json(new { total = datas.Length, data = datas }, JsonRequestBehavior.AllowGet));
        }
Пример #23
0
        // POST: /App/ApplyForm/Delete/
        public ActionResult Delete()
        {
            List <string> serialNumberList = new List <string>();

            ApplicationForm[] datas = ClassConvert <ApplicationForm> .Process(Request.Form);

            foreach (var data in datas)
            {
                serialNumberList.Add(data.SerialNumber);
                var result = _applicationFormService.Delete(data);
                if (result.ResultType != OperationResultType.Success)
                {
                    return(Json(new { error = result.ResultType.GetDescription(), total = datas.Length, data = datas }));
                }
            }
            _personalRecordService.Delete(serialNumberList);
            return(Json(new { total = datas.Length, data = datas }, JsonRequestBehavior.AllowGet));
        }
Пример #24
0
        public ActionResult Create()
        {
            string userid = ((System.Web.Security.FormsIdentity)(System.Web.HttpContext.Current.User.Identity)).Ticket.UserData;

            TopContactsVM[] datas = ClassConvert <TopContactsVM> .Process(Request.Form);

            datas[0].UserID = userid;
            var result = _topContactsService.Insert(datas[0]);

            if (result.ResultType != OperationResultType.Success)
            {
                return(Json(new { error = result.ResultType.GetDescription(), total = 1, data = this._topContactsService.TopContactss.ToArray() }));
            }
            else
            {
                TopContacts[] results = this._topContactsService.TopContactss.ToArray();
                return(Json(new { total = 1, data = new[] { results[results.Length - 1] } }));
            }
        }
Пример #25
0
        static void Main(string[] args)
        {
            while (true)
            {
                //  список прямых
                List <Line> lines = ReadLineList();

                // Получаем список  параллельных прямых
                ClassList  result      = new ClassList(lines);
                List <int> resultlines = result.Result();

                string Result = ClassConvert.ListToStr(resultlines);

                PrintLineList(Result);

                if (AskQuestion("Сохранить список в файл? y\n  "))
                {
                    SaveLineListInFile(Result);
                }
            }
        }
Пример #26
0
        public ActionResult CreatePersonal()
        {
            PersonalRecordVM[] recordVMs = ClassConvert <PersonalRecordVM> .Process(Request.Form);

            var result = _personalRecordService.Insert(recordVMs[0], true);
            var entity = new PersonalRecord
            {
                //Id = (int)System.DateTime.Now.Ticks,
                SerialNumber    = recordVMs[0].SerialNumber,
                Name            = recordVMs[0].Name,
                CertificateID   = recordVMs[0].CertificateID,
                CertificateType = recordVMs[0].CertificateType,
                Company         = recordVMs[0].Company,
                Tele            = recordVMs[0].Tele,
                PersonType      = recordVMs[0].PersonType,
                Nationality     = recordVMs[0].Nationality,
                Title           = recordVMs[0].Title,
                Amount          = recordVMs[0].Amount,
                TaxOrNot        = recordVMs[0].TaxOrNot,
                Bank            = recordVMs[0].Bank,
                BankDetailName  = recordVMs[0].BankDetailName,
                ProvinceCity    = recordVMs[0].ProvinceCity,
                CityField       = recordVMs[0].CityField,
                AccountName     = recordVMs[0].Name,
                AccountNumber   = recordVMs[0].AccountNumber,
                PaymentType     = recordVMs[0].PaymentType,
                Gender          = recordVMs[0].Gender,
                Birth           = recordVMs[0].Birth,
                UpdateDate      = DateTime.Now
            };

            if (result.ResultType != OperationResultType.Success)
            {
                return(Json(new { error = result.Message, total = 1, data = new[] { entity } }));
            }
            else
            {
                return(Json(new { total = 1, data = new[] { result.Data } }));
            }
        }
Пример #27
0
        public ActionResult SaveAction(V_TC_MDM_ALL mdmAll)
        {
            TC_PART_HS partHS = new TC_PART_HS();

            ClassConvert.DrawObj(mdmAll, partHS);

            M_PART mPart = new M_PART();

            mPart.PART_NO            = mdmAll.PART_NO;
            mPart.TC_CATEGORY_BY_MAN = mdmAll.TC_CATEGORY_BY_MAN;

            bool success = SaveTCPartData(partHS, mPart);

            if (success)
            {
                return(Content("success"));
            }
            else
            {
                return(Content("Fail"));
            }
        }
Пример #28
0
 private void dgvRecord_CellStateChanged(object sender, DataGridViewCellStateChangedEventArgs ev)
 {
     try
     {
         if (ev.StateChanged == DataGridViewElementStates.Selected)
         {
             Record record = Notes.records.Where(t => t.Name == ev.Cell.Value.ToString()).First();
             if (ev.Cell.Selected)
             {
                 setRecordsVisible(true);
                 tbRecordsKeys.Text  = ClassConvert.getKeyString(record.keyWords);
                 rtbRecordsText.Text = record.Text;
             }
             else
             {
                 record.Text     = rtbRecordsText.Text;
                 record.keyWords = ClassConvert.getKeysList(tbRecordsKeys.Text);
             }
         }
     }
     catch { }
 }
Пример #29
0
 private void dgvIdea_CellStateChanged(object sender, DataGridViewCellStateChangedEventArgs ev)
 {
     if (ev.StateChanged == DataGridViewElementStates.Selected)
     {
         try
         {
             if (ev.Cell.Selected)
             {
                 setIdeaVisible(true);
                 Idea idea = Notes.ideas.Where(t => t.Name == ev.Cell.Value.ToString()).First();
                 rtbIdeaRext.Text = idea.Text;
                 tbIdeaKeys.Text  = ClassConvert.getKeyString(idea.keyWords);
             }
             else
             {
                 Idea idea = Notes.ideas.Where(t => t.Name == ev.Cell.Value.ToString()).First();
                 idea.Text     = rtbIdeaRext.Text;
                 idea.keyWords = ClassConvert.getKeysList(tbIdeaKeys.Text);
             }
         }
         catch { }
     }
 }
Пример #30
0
        public ActionResult UploadCustLoadFile()
        {
            try
            {
                HttpPostedFileBase fb         = Request.Files[0];
                string             tempGuid   = Guid.NewGuid().ToString();
                string             folderPath = Server.MapPath(CHubConstValues.ChubTempFolder);
                FileInfo           folder     = new FileInfo(folderPath);
                if (!Directory.Exists(folder.FullName))
                {
                    Directory.CreateDirectory(folder.FullName);
                }

                //fb.filename - to get short file name parse string
                string        errorLogName     = DateTime.Now.ToString("yyyy_MM_dd_HH_mm_ss") + tempGuid + ".txt";
                string        errorLogWebName  = "/temp/" + errorLogName;
                string        errorLogFullName = folder.FullName + errorLogName;
                TxtLog        txtLog           = new TxtLog();
                StringBuilder errorMsg         = new StringBuilder();
                errorMsg.AppendLine(string.Format("Current User:{0}", Session[CHubConstValues.SessionUser].ToString()));

                string fileFullName = folder.FullName + tempGuid + ".xlsx";
                fb.SaveAs(fileFullName);

                NPOIExcelHelper excelHelper = new NPOIExcelHelper(fileFullName);
                DataTable       dt          = excelHelper.ExcelToDataTable();
                //Delete temp file
                System.IO.File.Delete(fileFullName);

                if (dt == null || dt.Rows.Count == 0)
                {
                    return(Content("No data in excel"));
                }

                //DataTable dt = ExcelHelper.GetDTFromExcel(fileFullName);
                List <ITT_CUST_LOAD> modelList = ClassConvert.ConvertDT2List <ITT_CUST_LOAD>(dt);

                if (modelList == null || modelList.Count == 0)
                {
                    return(Content("wrong excel strut"));
                }

                int successCount = 0;
                int failCount    = 0;
                foreach (var item in modelList)
                {
                    string msg = SaveCustLoadAction(item);
                    if (string.IsNullOrEmpty(msg))
                    {
                        successCount++;
                        LogHelper.WriteLog(string.Format("willBillNo:{0},data:{1}", item.WILL_BILL_NO, JsonConvert.SerializeObject(item)));
                    }
                    else
                    {
                        failCount++;
                        LogHelper.WriteErrorLog(string.Format("willBillNo:{0},message:{1},data:{2}", item.WILL_BILL_NO, msg, JsonConvert.SerializeObject(item)));
                        errorMsg.AppendLine(string.Format("willBillNo:{0},message:{1},data:{2}", item.WILL_BILL_NO, msg, JsonConvert.SerializeObject(item)));
                    }
                }

                bool success = true;
                if (failCount > 0)
                {
                    txtLog.log(errorMsg.ToString(), errorLogFullName);
                    success = false;
                }
                return(Json(new RequestResult(success, string.Format("Total Lines:{0}, Success items:{1}, Fail items:{2}", modelList.Count, successCount, failCount), errorLogWebName)));
                //return Content(string.Format("Total Lines:{0}, Success items:{1}, Fail items:{2}", modelList.Count, successCount, failCount));
            }
            catch (Exception ex)
            {
                LogHelper.WriteLog("save Cust load", ex);
                return(Json(new RequestResult(false, ex.Message)));
            }
        }