コード例 #1
0
        static void Main(string[] args)
        {
            // Date and Time handling
            DateTimeExamples DTE = new DateTimeExamples();
            //DateTimeExamples.OutputCurrentTime();

            // Array handling
            ArrayExamples AE = new ArrayExamples();
            ArrayExamples.ArrayFunc();

            // Collections handling
            CollectionExamples CE = new CollectionExamples();
            CollectionExamples.CollectionFunc();

            // Classes 101
            ClassExamples1 CE1 = new ClassExamples1();
            ClassExamples1.ClassExamples1Func();

            // Classes 102
            ClassExamples2 CE2 = new ClassExamples2();
            ClassExamples2.ClassExamples2Func();

            // Classes 103
            ClassExamples3 CE3 = new ClassExamples3();
            ClassExamples3.ClassExamples3Func();

            // Extension Methods
            ExtensionMethods EM1 = new ExtensionMethods();
            ExtensionMethods.ExtensionMethodsFunc();

            Environment.ExitCode = 1;
        }
コード例 #2
0
        // remove to GinngerRunner.SetBFOfflineData
        public bool OfflineBusinessFlowExecutionLog(BusinessFlow businessFlow, string logFolderPath)
        {
            try
            {
                //handle root directory
                if (Directory.Exists(logFolderPath))
                {
                    executionLoggerHelper.CleanDirectory(logFolderPath);
                }
                else
                {
                    Directory.CreateDirectory(logFolderPath);
                }
                GingerRunner Gr = new GingerRunner();
                mCurrentBusinessFlow = businessFlow;
                businessFlow.OffilinePropertiesPrep(logFolderPath);
                System.IO.Directory.CreateDirectory(businessFlow.ExecutionLogFolder);
                foreach (Activity activity in businessFlow.Activities)
                {
                    ActivitiesGroup currentActivityGroup = businessFlow.ActivitiesGroups.Where(x => x.ActivitiesIdentifiers.Select(z => z.ActivityGuid).ToList().Contains(activity.Guid)).FirstOrDefault();
                    if (currentActivityGroup != null)
                    {
                        currentActivityGroup.ExecutionLogFolder = logFolderPath;
                        switch (currentActivityGroup.ExecutionLoggerStatus)
                        {
                        case executionLoggerStatus.NotStartedYet:
                            ActivityGroupStart(meventtime, currentActivityGroup);
                            break;
                        }
                    }

                    Gr.CalculateActivityFinalStatus(activity);
                    if (activity.GetType() == typeof(IErrorHandler))
                    {
                        continue;
                    }
                    if (activity.Status != Amdocs.Ginger.CoreNET.Execution.eRunStatus.Passed && activity.Status != Amdocs.Ginger.CoreNET.Execution.eRunStatus.Failed && activity.Status != Amdocs.Ginger.CoreNET.Execution.eRunStatus.Stopped)
                    {
                        continue;
                    }

                    mCurrentActivity = activity;
                    activity.OfflinePropertiesPrep(businessFlow.ExecutionLogFolder, businessFlow.ExecutionLogActivityCounter, ExtensionMethods.folderNameNormalazing(activity.ActivityName));
                    System.IO.Directory.CreateDirectory(activity.ExecutionLogFolder);
                    foreach (Act action in activity.Acts)
                    {
                        if (action.Status != Amdocs.Ginger.CoreNET.Execution.eRunStatus.Passed && action.Status != Amdocs.Ginger.CoreNET.Execution.eRunStatus.Failed && action.Status != Amdocs.Ginger.CoreNET.Execution.eRunStatus.Stopped && action.Status != Amdocs.Ginger.CoreNET.Execution.eRunStatus.FailIgnored)
                        {
                            continue;
                        }
                        activity.ExecutionLogActionCounter++;
                        action.ExecutionLogFolder = Path.Combine(activity.ExecutionLogFolder, activity.ExecutionLogActionCounter + " " + ExtensionMethods.folderNameNormalazing(action.Description));
                        System.IO.Directory.CreateDirectory(action.ExecutionLogFolder);

                        ActionEnd(meventtime, action, true);
                    }
                    ActivityEnd(meventtime, activity, true);
                    businessFlow.ExecutionLogActivityCounter++;
                }
                Gr.SetActivityGroupsExecutionStatus(businessFlow, true);
                Gr.CalculateBusinessFlowFinalStatus(businessFlow);

                BusinessFlowEnd(meventtime, businessFlow, true);
                businessFlow.ExecutionLogFolder = string.Empty;
                return(true);
            }
            catch (Exception ex)
            {
                Reporter.ToLog(eLogLevel.ERROR, "Execution Logger Failed to do Offline BusinessFlow Execution Log", ex);
                return(false);
            }
        }
コード例 #3
0
 public void Should_work_for_nullables()
 {
     Assert.AreEqual(ExtensionMethods.GetUnderlyingType(typeof(int?)), typeof(int));
     Assert.AreEqual(ExtensionMethods.GetUnderlyingType(typeof(DateTime?)), typeof(DateTime));
     Assert.AreEqual(ExtensionMethods.GetUnderlyingType(typeof(Guid?)), typeof(Guid));
 }
コード例 #4
0
 public void Should_identify_unmatched_types()
 {
     Assert.IsFalse(ExtensionMethods.AreMatchingSimpleTypes("string", "Int"));
 }
コード例 #5
0
 public static void PrintExtension()
 {
     ExtensionMethods cityExtention = new ExtensionMethods();
     cityExtention.QueryCities();
 }
コード例 #6
0
ファイル: BackupHelper.cs プロジェクト: duhowise/POS-WPF
 public Task <string> CreateBackupAsync(string backupLocation, string databaseName, char reason)
 {
     ExtensionMethods.PublishEvent <EventAggregator>(EventServiceFactory.EventService, "Reset Cache", true);
     ExtensionMethods.PublishEvent <EventAggregator>(EventServiceFactory.EventService, "CloseManagementTabs", true);
     return(_backupService.CreateDatabaseBackupAsync(backupLocation, databaseName, reason));
 }
コード例 #7
0
        public JsonResult Guardar(ClienteModel model)
        {
            var rm = new ResponseModel();

            if (!ModelState.IsValid)
            {
                rm.message  = "Hubo un problema verifique sus datos e intente de nuevo.";
                rm.message += ExtensionMethods.GetAllErrorsFromModelState(this);
                return(Json(rm, JsonRequestBehavior.AllowGet));
            }
            try
            {
                ClienteDAO dao    = new ClienteDAO();
                var        entity = dao.GetById(model.idCliente, db);
                bool       nuevo  = false;
                string     error  = "";

                if (entity == null)
                {
                    if (!validarInsersion(ref model, ref error))
                    {
                        rm.message = error;
                        return(Json(rm, JsonRequestBehavior.AllowGet));
                    }

                    entity           = new cliente();
                    entity.direccion = new direccion();
                    nuevo            = true;
                }
                else
                {
                    if (!validarModificacion(ref model, ref entity, ref error))
                    {
                        rm.message = error;
                        return(Json(rm, JsonRequestBehavior.AllowGet));
                    }
                }

                if (model.esPersonaFisica)
                {
                    entity.TIPO_PERSONA     = "Fisica";
                    entity.NOMBRE           = ExtensionMethods.Trim(model.nombrePersona);
                    entity.APELLIDO_PATERNO = ExtensionMethods.Trim(model.apellidoPaterno);
                    entity.APELLIDO_MATERNO = ExtensionMethods.Trim(model.apellidoMaterno);

                    entity.EMPRESA      = null;
                    entity.RAZON_SOCIAL = null;
                }
                else
                {
                    entity.TIPO_PERSONA = "Moral";
                    entity.EMPRESA      = ExtensionMethods.Trim(model.nombreEmpresa);
                    entity.RAZON_SOCIAL = ExtensionMethods.Trim(model.razonSocial);

                    entity.NOMBRE           = null;
                    entity.APELLIDO_PATERNO = null;
                    entity.APELLIDO_MATERNO = null;
                }

                entity.TELEFONO              = model.telefono;
                entity.CELULAR               = model.celular;
                entity.EMAIL                 = model.correo;
                entity.RFC                   = model.rfc;
                entity.REFERENCIA_BANCARIA   = model.referencia;
                entity.ACTIVO                = model.Activo;
                entity.CLABE                 = model.Clabe;
                entity.REFERENCIA_BANCARIA_2 = model.referencia2;

                entity.ES_CLIENTE_CREDITO = model.esClienteCredito;

                if (model.esClienteCredito)
                {
                    entity.SALDO         = ExtensionMethods.ConverToDecimalFormat(model.saldo);
                    entity.MONTO_CREDITO = ExtensionMethods.ConverToDecimalFormat(model.creditoMaximo);
                }
                entity.ACTIVO = model.Activo;

                //Agregar persona contacto si la hay
                var contacto = entity.persona_contacto != null ? entity.persona_contacto : new persona_contacto();
                if (model.nombreContacto != null && model.nombreContacto != string.Empty)
                {
                    contacto.NOMBRE   = model.nombreContacto;
                    contacto.EMAIL    = model.correoContacto;
                    contacto.TELEFONO = model.telefonoContacto;

                    entity.persona_contacto = contacto;
                }
                else
                {
                    entity.persona_contacto = null;
                }
                //Agregar persona contacto #2 si la hay
                var contacto2 = entity.persona_contacto1 != null ? entity.persona_contacto1: new persona_contacto();
                if (model.nombreContacto2 != null && model.nombreContacto2 != string.Empty)
                {
                    contacto2.NOMBRE   = model.nombreContacto2;
                    contacto2.EMAIL    = model.correoContacto2;
                    contacto2.TELEFONO = model.telefonoContacto2;

                    entity.persona_contacto1 = contacto2;
                }
                else
                {
                    entity.persona_contacto1 = null;
                }

                //agregar direccion
                entity.direccion.CALLE        = model.calle;
                entity.direccion.NUM_EXTERIOR = model.numExterior;
                entity.direccion.NUM_INTERIOR = model.numInterior;
                entity.direccion.COLONIA      = model.colonia;
                entity.direccion.CIUDAD       = model.ciudad;
                entity.direccion.MUNICIPIO    = model.municipio;
                entity.direccion.ID_ESTADO    = model.estado;
                entity.direccion.ID_PAIS      = model.pais;
                entity.direccion.CP           = model.codigoPostal;

                //datos de cuenta
                if (model.cuenta != null && model.cuenta != "")
                {
                    entity.cuenta = entity.cuenta == null ? new cuenta() : entity.cuenta;
                    entity.cuenta.NUMERO_CUENTA = model.cuenta;
                    entity.cuenta.ID_BANCO      = model.banco;
                    entity.cuenta.TIPO          = model.tipoCuenta;
                }
                else
                {
                    entity.cuenta = null;
                }

                if (nuevo)
                {
                    db.cliente.Add(entity);
                }

                if (db.SaveChanges() > 0 || db.Entry(entity).State == EntityState.Unchanged)
                {
                    rm.response = true;
                    rm.message  = null; //"Sus datos se guardaron correctamente";
                    if (nuevo)
                    {
                        rm.href = "Index";
                    }
                    else
                    {
                        rm.href = "self";
                    }
                    TempData["message"] = "success,Sus datos se guardaron correctamente";
                }
            }
            catch (Exception e)
            {
                rm.SetResponse(false, e.Message);
                // LogUtil.ExceptionLog(e);
            }

            return(Json(rm, JsonRequestBehavior.AllowGet));
        }
コード例 #8
0
 private void C_GotFocus(object sender, EventArgs e)
 {
     ExtensionMethods.DisableAllTextBoxAndComboBox(this, (Control)sender);
     return;
 }
コード例 #9
0
        protected void proceedtoUpload_Click(object sender, EventArgs e)
        {
            var    tenantId = long.Parse(SessionHelper.GetTenantID(HttpContext.Current.Session));
            string fId      = FileID.Value;

            //long preaId = 0;



            if (!string.IsNullOrEmpty(fId))
            {
                string ext = EXT.Value;

                var             data   = File.ReadAllBytes(fId);
                ImportFromExcel import = new ImportFromExcel();
                if (ext == ".xls")
                {
                    import.LoadXls(data);
                }
                else if (ext == ".xlsx")
                {
                    import.LoadXlsx(data);
                }
                //first parameter it's the sheet number in the excel workbook
                //second paramter it's the number of rows to skip at the start(we have an header in the file)
                List <QuestionUploadModel> all = import.ExcelToList <QuestionUploadModel>(0, 1);

                if (all.Count() < 1)
                {
                    resultLbl.Text = "Either you uploaded an empty file or you provided wrong file type. Only allowed file type is .csv, .xls or.xlsx!";
                }
                else
                {
                    resultLbl.Text = "";
                    var Qtype = DropDownList1.SelectedValue;
                    var ex    = 0;
                    var obj   = new List <object>();
                    foreach (var s in all)
                    {
                        ex += _db.SearchQuestion(s.Question.ToLower()).Where(x => x.TypeId == long.Parse(Qtype)).Count();
                        T_Question q = new T_Question
                        {
                            PreambleId = 0,
                            TypeId     = long.Parse(Qtype),
                            OptionType = (long)ErecruitHelper.OptionType.Single,
                            IsActive   = true,
                            Details    = s.Question,
                            Section    = s.Section,
                            TenantId   = tenantId,
                            AddedBy    = SessionHelper.FetchEmail(Session),
                            DateAdded  = DateTime.Now
                        };
                        _db.T_Question.Add(q);
                        _db.SaveChanges();
                        var opts = new List <T_Option>();
                        if (!string.IsNullOrEmpty(s.A))
                        {
                            opts.Add(new T_Option
                            {
                                Q_Id      = q.Id,
                                Details   = s.A,
                                Answer    = s.Answer == ErecruitHelper.OptionIndex.A.ToString(),
                                AddedBy   = SessionHelper.FetchEmail(Session),
                                DateAdded = DateTime.Now
                            });
                        }
                        if (!string.IsNullOrEmpty(s.B))
                        {
                            opts.Add(new T_Option
                            {
                                Q_Id      = q.Id,
                                Details   = s.B,
                                Answer    = s.Answer == ErecruitHelper.OptionIndex.B.ToString(),
                                AddedBy   = SessionHelper.FetchEmail(Session),
                                DateAdded = DateTime.Now
                            });
                        }
                        if (!string.IsNullOrEmpty(s.C))
                        {
                            opts.Add(new T_Option
                            {
                                Q_Id      = q.Id,
                                Details   = s.C,
                                Answer    = s.Answer == ErecruitHelper.OptionIndex.C.ToString(),
                                AddedBy   = SessionHelper.FetchEmail(Session),
                                DateAdded = DateTime.Now
                            });
                        }
                        if (!string.IsNullOrEmpty(s.D))
                        {
                            opts.Add(new T_Option
                            {
                                Q_Id      = q.Id,
                                Details   = s.D,
                                Answer    = s.Answer == ErecruitHelper.OptionIndex.D.ToString(),
                                AddedBy   = SessionHelper.FetchEmail(Session),
                                DateAdded = DateTime.Now
                            });
                        }
                        if (!string.IsNullOrEmpty(s.E))
                        {
                            opts.Add(new T_Option
                            {
                                Q_Id      = q.Id,
                                Details   = s.E,
                                Answer    = s.Answer == ErecruitHelper.OptionIndex.E.ToString(),
                                AddedBy   = SessionHelper.FetchEmail(Session),
                                DateAdded = DateTime.Now
                            });
                        }
                        ExtensionMethods.InsertAllOnSubmit(_db.T_Option, opts);
                        //_db.T_Option.InsertAllOnSubmit(opts);
                        _db.SaveChanges();
                    }
                    if (ex > 0)
                    {
                        resultLbl.Text = "Some Question(s) already exist in the system therefore were skipped.";
                    }
                    else
                    {
                        resultLbl.Text = "Questions Uploaded";
                    }
                }
            }
            else
            {
                resultLbl.Text = "No file to upload. Kindly chose a file.";
            }
        }
コード例 #10
0
        protected void Save_Click(object sender, EventArgs e)
        {
            try
            {
                // var all = new List<string[]>();
                var    tenantId = long.Parse(SessionHelper.GetTenantID(HttpContext.Current.Session));
                string fId      = FileID.Value;
                //long preaId = 0;



                if (!string.IsNullOrEmpty(fId))
                {
                    string ext = EXT.Value;
                    //all = ErecruitHelper.GetLinesFromFile(fId, ext);

                    var             data   = File.ReadAllBytes(fId);
                    ImportFromExcel import = new ImportFromExcel();
                    if (ext == ".xls")
                    {
                        import.LoadXls(data);
                    }
                    else if (ext == ".xlsx")
                    {
                        import.LoadXlsx(data);
                    }
                    //first parameter it's the sheet number in the excel workbook
                    //second paramter it's the number of rows to skip at the start(we have an header in the file)
                    List <QuestionUploadModel> all = import.ExcelToList <QuestionUploadModel>(0, 1);

                    if (all.Count() < 1)
                    {
                        resultLbl.Text = "Either you uploaded an empty file or you provided wrong file type. Only allowed file type is .csv, .xls or.xlsx!";
                    }
                    else
                    {
                        resultLbl.Text = "";
                        var Qtype = DropDownList1.SelectedValue;
                        var ex    = 0;
                        var obj   = new List <object>();
                        foreach (var s in all)
                        {
                            ex += _db.SearchQuestion(s.Question.ToLower()).Where(x => x.TypeId == long.Parse(Qtype)).Count();
                            T_Question q = new T_Question
                            {
                                PreambleId = 0,
                                TypeId     = long.Parse(Qtype),
                                OptionType = (long)ErecruitHelper.OptionType.Single,
                                IsActive   = true,
                                Details    = s.Question,
                                TenantId   = tenantId,
                                Section    = s.Section,
                                AddedBy    = SessionHelper.FetchEmail(Session),
                                DateAdded  = DateTime.Now
                            };
                            _db.T_Question.Add(q);
                            _db.SaveChanges();
                            var opts = new List <T_Option>();
                            if (!string.IsNullOrEmpty(s.A))
                            {
                                opts.Add(new T_Option
                                {
                                    Q_Id      = q.Id,
                                    Details   = s.A,
                                    Answer    = s.Answer == ErecruitHelper.OptionIndex.A.ToString(),
                                    AddedBy   = SessionHelper.FetchEmail(Session),
                                    DateAdded = DateTime.Now
                                });
                            }
                            if (!string.IsNullOrEmpty(s.B))
                            {
                                opts.Add(new T_Option
                                {
                                    Q_Id      = q.Id,
                                    Details   = s.B,
                                    Answer    = s.Answer == ErecruitHelper.OptionIndex.B.ToString(),
                                    AddedBy   = SessionHelper.FetchEmail(Session),
                                    DateAdded = DateTime.Now
                                });
                            }
                            if (!string.IsNullOrEmpty(s.C))
                            {
                                opts.Add(new T_Option
                                {
                                    Q_Id      = q.Id,
                                    Details   = s.C,
                                    Answer    = s.Answer == ErecruitHelper.OptionIndex.C.ToString(),
                                    AddedBy   = SessionHelper.FetchEmail(Session),
                                    DateAdded = DateTime.Now
                                });
                            }
                            if (!string.IsNullOrEmpty(s.D))
                            {
                                opts.Add(new T_Option
                                {
                                    Q_Id      = q.Id,
                                    Details   = s.D,
                                    Answer    = s.Answer == ErecruitHelper.OptionIndex.D.ToString(),
                                    AddedBy   = SessionHelper.FetchEmail(Session),
                                    DateAdded = DateTime.Now
                                });
                            }
                            if (!string.IsNullOrEmpty(s.E))
                            {
                                opts.Add(new T_Option
                                {
                                    Q_Id      = q.Id,
                                    Details   = s.E,
                                    Answer    = s.Answer == ErecruitHelper.OptionIndex.E.ToString(),
                                    AddedBy   = SessionHelper.FetchEmail(Session),
                                    DateAdded = DateTime.Now
                                });
                            }
                            // _db.T_Option.InsertAllOnSubmit(opts);
                            ExtensionMethods.InsertAllOnSubmit(_db.T_Option, opts);
                            _db.SaveChanges();
                        }
                        if (ex > 0)
                        {
                            resultLbl.Text = "Some Question(s) already exist in the system therefore were skipped.";
                        }
                        else
                        {
                            resultLbl.Text = "Questions Uploaded";
                        }
                    }
                }
                else
                {
                    HttpPostedFile file = QuestionFile.PostedFile;

                    if (file != null && file.ContentLength > 0)
                    {
                        string fname  = Path.GetFileName(file.FileName);
                        string ext    = System.IO.Path.GetExtension(file.FileName);
                        string fileID = Guid.NewGuid().ToString();
                        string path   = "";
                        // var all =  new List<string[]>();
                        if (Directory.Exists(Server.MapPath("~/UploadedQuestions/")))
                        {
                            path = Server.MapPath(Path.Combine("~/UploadedQuestions/", fileID + ext));
                            // PPath = Path.Combine("~/Passports/", cand.Code + ext);
                            file.SaveAs(path);
                        }
                        else
                        {
                            Directory.CreateDirectory(Server.MapPath("~/UploadedQuestions/"));
                            path = Server.MapPath(Path.Combine("~/UploadedQuestions/", fileID + ext));
                            // PPath = Path.Combine("~/Passports/", cand.Code + ext);
                            file.SaveAs(path);
                        }
                        var             data   = File.ReadAllBytes(path);
                        ImportFromExcel import = new ImportFromExcel();
                        if (ext == ".xls")
                        {
                            import.LoadXls(data);
                        }
                        else if (ext == ".xlsx")
                        {
                            import.LoadXlsx(data);
                        }
                        //first parameter it's the sheet number in the excel workbook
                        //second paramter it's the number of rows to skip at the start(we have an header in the file)
                        List <QuestionUploadModel> all = import.ExcelToList <QuestionUploadModel>(0, 1);

                        if (all.Count() < 1)
                        {
                            resultLbl.Text = "Either you uploaded an empty file or you provided wrong file type. Only allowed file type is .csv, .xls or.xlsx!";
                        }
                        else
                        {
                            resultLbl.Text = "";
                            var Qtype = DropDownList1.SelectedValue;
                            var ex    = 0;
                            var obj   = new List <object>();
                            foreach (var s in all)
                            {
                                ex += _db.SearchQuestion(s.Question.ToLower()).Where(x => x.TypeId == long.Parse(Qtype)).Count();
                                T_Question q = new T_Question
                                {
                                    PreambleId = 0,
                                    TypeId     = long.Parse(Qtype),
                                    OptionType = (long)ErecruitHelper.OptionType.Single,
                                    IsActive   = true,
                                    Details    = s.Question,
                                    Section    = s.Section,
                                    TenantId   = tenantId,
                                    AddedBy    = SessionHelper.FetchEmail(Session),
                                    DateAdded  = DateTime.Now
                                };
                                _db.T_Question.Add(q);
                                _db.SaveChanges();
                                var opts = new List <T_Option>();
                                if (!string.IsNullOrEmpty(s.A))
                                {
                                    opts.Add(new T_Option
                                    {
                                        Q_Id      = q.Id,
                                        Details   = s.A,
                                        Answer    = s.Answer == ErecruitHelper.OptionIndex.A.ToString(),
                                        AddedBy   = SessionHelper.FetchEmail(Session),
                                        DateAdded = DateTime.Now
                                    });
                                }
                                if (!string.IsNullOrEmpty(s.B))
                                {
                                    opts.Add(new T_Option
                                    {
                                        Q_Id      = q.Id,
                                        Details   = s.B,
                                        Answer    = s.Answer == ErecruitHelper.OptionIndex.B.ToString(),
                                        AddedBy   = SessionHelper.FetchEmail(Session),
                                        DateAdded = DateTime.Now
                                    });
                                }
                                if (!string.IsNullOrEmpty(s.C))
                                {
                                    opts.Add(new T_Option
                                    {
                                        Q_Id      = q.Id,
                                        Details   = s.C,
                                        Answer    = s.Answer == ErecruitHelper.OptionIndex.C.ToString(),
                                        AddedBy   = SessionHelper.FetchEmail(Session),
                                        DateAdded = DateTime.Now
                                    });
                                }
                                if (!string.IsNullOrEmpty(s.D))
                                {
                                    opts.Add(new T_Option
                                    {
                                        Q_Id      = q.Id,
                                        Details   = s.D,
                                        Answer    = s.Answer == ErecruitHelper.OptionIndex.D.ToString(),
                                        AddedBy   = SessionHelper.FetchEmail(Session),
                                        DateAdded = DateTime.Now
                                    });
                                }
                                if (!string.IsNullOrEmpty(s.E))
                                {
                                    opts.Add(new T_Option
                                    {
                                        Q_Id      = q.Id,
                                        Details   = s.E,
                                        Answer    = s.Answer == ErecruitHelper.OptionIndex.E.ToString(),
                                        AddedBy   = SessionHelper.FetchEmail(Session),
                                        DateAdded = DateTime.Now
                                    });
                                }
                                ExtensionMethods.InsertAllOnSubmit(_db.T_Option, opts);
                                //_db.T_Option.InsertAllOnSubmit(opts);
                                _db.SaveChanges();
                            }
                            if (ex > 0)
                            {
                                resultLbl.Text = "Some Question(s) already exist in the system therefore were skipped.";
                            }
                            else
                            {
                                resultLbl.Text = "Questions Uploaded";
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                ErecruitHelper.SetErrorData(ex, Session);
                Response.Redirect("ErrorPage.aspx", false);
            }
        }
コード例 #11
0
ファイル: Gun.cs プロジェクト: okoz/ld32
 private void SetSliderValue(float value)
 {
     FireStatus.value           = Mathf.Clamp(value, 0.0f, 1.0f);
     FireStatusBackground.color = ExtensionMethods.FromHSV((1.0f - FireStatus.value) * 100.0f, 1.0f, 1.0f);
     FireStatusForeground.color = FireStatusBackground.color;
 }
コード例 #12
0
 public void GetSmallestElementFromPointTest_NoElementsProvided()
 {
     Assert.ThrowsException <ArgumentException>(() => ExtensionMethods.GetSmallestElementFromPoint(new Dictionary <int, ICoreA11yElement>(), System.Drawing.Point.Empty));
 }
コード例 #13
0
 public void GetSmallestElementFromPointTest_NullArgument()
 {
     Assert.ThrowsException <ArgumentNullException>(() => ExtensionMethods.GetSmallestElementFromPoint(null, System.Drawing.Point.Empty));
 }
コード例 #14
0
        public ActionResult GetTaskRemarks()
        {
            var remarks = ExtensionMethods.ToSelectList <TaskRemarks>();

            return(Json(remarks, JsonRequestBehavior.AllowGet));
        }
コード例 #15
0
        /// <summary>
        /// Copies the user type permissions for single user.
        /// </summary>
        /// <param name="user">The user.</param>
        public void CopyPermissionsForSingleUser(IUser user)
        {
            if (!user.IsAdmin() && !user.Disabled())
            {

                // Variables.
                var permissions = GetUserTypePermissions(user.UserType);
                var contentService = ApplicationContext.Current.Services.ContentService;
                var nodesById = new Dictionary<int, IContent>();
                var node = default(IContent);
                var userId = new [] { user.Id };


                // Apply each permission.
                foreach (var permission in permissions)
                {

                    // Get node (try cache first).
                    if (!nodesById.TryGetValue(permission.NodeId, out node))
                    {
                        node = contentService.GetById(permission.NodeId);
                        nodesById[permission.NodeId] = node;
                    }


                    // Apply permission to node.
                    if (!string.IsNullOrWhiteSpace(permission.PermissionId) && node != null)
                    {
                        var permissionId = permission.PermissionId[0];
                        contentService.AssignContentPermission(node, permissionId, userId);
                    }

                }

            }
        }
コード例 #16
0
        public ActionResult GetTaskStatus()
        {
            var status = ExtensionMethods.ToSelectList <TaskStatus>();

            return(Json(status, JsonRequestBehavior.AllowGet));
        }
コード例 #17
0
        public async Task Attack([Remainder] string Input = null)
        {
            try
            {
                string[] lol = ExtensionMethods.GenericSplit(Input, " ");
                int      val = 0;
                if (lol.Length > 1 && int.Parse(lol[1]) > 0)
                {
                    val = int.Parse(lol[1]);
                }
                if (lol[0].ToLower() == "help")
                {
                    await Context.User.SendMessageAsync("Attack an enemy! Type !nep enemies to get a list of what you can attack. Example type !nep attack wolf (number). You can perform multiple attacks in a row (up to 10 attacks) but your HP will not recover after each fight. If you die, you lose all gained exp so " +
                                                        "use this wisely!");

                    return;
                }
                if (!Program.IsOnPlayerData(Context))
                {
                    Program.PlayerData.Add(new PlayerData(Context.User.Id));
                }
                PlayerData pd     = PlayerD(Context.User.Id);
                UserData   ud     = ExtensionMethods.FindPerson(Context.User.Id);
                int        atkAmt = ud.NonLevel / 2;
                if (atkAmt < 1)
                {
                    atkAmt = 1;
                }
                if (val > atkAmt)
                {
                    await Context.Channel.SendMessageAsync($"You can only attack {atkAmt} times in a row. This is your ooc chat level / 2 rounded down.");

                    return;
                }
                lol[0] = lol[0].ToLower();
                CreateEntity enemy = null;
                foreach (CreateEntity x in CreateEntity.Enemies)
                {
                    if (x.ReturnAIName.ToLower() == lol[0])
                    {
                        enemy = x.SpawnEnemy;
                        break;
                    }
                }
                if (enemy == null)
                {
                    await Context.Channel.SendMessageAsync("Null");
                }
                if (pd.combat != null && pd.combat.inCombat)
                {
                    await Context.User.SendMessageAsync("You're already in a battle. Please wait until it's done.");

                    return;
                }
                Combat c = new Combat(enemy, pd, Context.User.Username, Context, ud, val);
                c = null;
            }
            catch (Exception m)
            {
                ExtensionMethods.WriteToLog(ExtensionMethods.LogType.ErrorLog, m, "from attack method");
            }

            //await Context.User.SendMessageAsync("Here are your combat results:\n" + c.ReportLog);
        }
コード例 #18
0
 private void frmPaymentToSupplier_FormClosing(object sender, FormClosingEventArgs e)
 {
     ExtensionMethods.RemoveTransactionFormToPanel(this, ExtensionMethods.MainPanel);
 }
コード例 #19
0
ファイル: Emit.Call.cs プロジェクト: JaCoB1123/Sigil
        private void InjectTailCall()
        {
            for (var i = 0; i < IL.Index; i++)
            {
                var instr = IL[i];
                BufferedILInstruction call = null;

                if (instr.IsInstruction == OpCodes.Ret)
                {
                    int callIx = -1;

                    for (var j = i - 1; j >= 0; j--)
                    {
                        var atJ = IL[j];

                        if (atJ.MarksLabel != null)
                        {
                            break;
                        }

                        if (atJ.IsInstruction.HasValue)
                        {
                            if (ExtensionMethods.IsTailableCall(atJ.IsInstruction.Value))
                            {
                                callIx = j;
                                call   = atJ;
                            }

                            break;
                        }
                    }

                    if (callIx == -1)
                    {
                        continue;
                    }
                    if (call.TakesManagedPointer())
                    {
                        continue;
                    }
#if !COREFX // see https://github.com/dotnet/corefx/issues/4543 item 4
                    if (call.TakesTypedReference())
                    {
                        continue;
                    }
#endif
                    if (call.TakesByRefArgs())
                    {
                        continue;
                    }

                    var callReturns     = call.MethodReturnType;
                    var delegateReturns = ReturnType.Type;

                    // the method's return types not matching
                    //   means we can't just turn the call into a jump
                    //   since _something_ has to preceed or survive the call to
                    //   make the ret legal
                    if (!ExtensionMethods.IsAssignableFrom(delegateReturns, callReturns))
                    {
                        continue;
                    }

                    // there's one case not being handled explicitly here,
                    //   which is the call must consume the _entire_ stack.
                    // we don't have to asset it because the return type
                    //   comparison is sufficient:
                    //     - if the types match, the stack must be empty
                    //         or the following ret will fail to verify (since
                    //         there's an extra item of the corret type on the stack)
                    //     - if the types _don't_ match, we've already bailed on the
                    //         tail injection

                    InsertInstruction(callIx, OpCodes.Tailcall);
                    i++;
                }
            }
        }
コード例 #20
0
        private void CopiarEntidadModelo(ref ClienteModel model, cliente entity, ArtexConnection db)
        {
            try
            {
                model           = new ClienteModel();
                model.idCliente = entity.ID;

                model.bancosList = BancoDAO.GetAlls();

                model.saldo            = ExtensionMethods.ToMoneyFormat(entity.SALDO);
                model.creditoMaximo    = ExtensionMethods.ToMoneyFormat(entity.MONTO_CREDITO);
                model.esClienteCredito = entity.ES_CLIENTE_CREDITO;
                model.rfc         = entity.RFC;
                model.referencia  = entity.REFERENCIA_BANCARIA;
                model.correo      = entity.EMAIL;
                model.celular     = entity.CELULAR;
                model.telefono    = entity.TELEFONO;
                model.Activo      = entity.ACTIVO;
                model.referencia2 = entity.REFERENCIA_BANCARIA_2;
                model.Clabe       = entity.CLABE;


                if (entity.TIPO_PERSONA == "Fisica")
                {
                    model.esPersonaFisica = true;
                    model.nombrePersona   = entity.NOMBRE;
                    model.apellidoPaterno = entity.APELLIDO_PATERNO;
                    model.apellidoMaterno = entity.APELLIDO_MATERNO;
                }
                else
                {
                    model.esPersonaFisica = false;
                    model.nombreEmpresa   = entity.EMPRESA;
                    model.razonSocial     = entity.RAZON_SOCIAL;
                }
                //datos de cuenta
                var cuenta = entity.cuenta;
                if (cuenta != null)
                {
                    model.cuenta     = cuenta.NUMERO_CUENTA;
                    model.tipoCuenta = cuenta.TIPO;
                    model.banco      = cuenta.ID_BANCO;
                }
                //datos de contacto
                var contacto = entity.persona_contacto;
                if (contacto != null)
                {
                    model.nombreContacto          = contacto.NOMBRE;
                    model.apellidoPaternoContacto = contacto.APELLIDO_PATERNO;
                    model.apellidoMaternoContacto = contacto.APELLIDO_MATERNO;
                    model.correoContacto          = contacto.EMAIL;
                    model.telefonoContacto        = contacto.TELEFONO;
                }
                var contacto2 = entity.persona_contacto1;
                if (contacto2 != null)
                {
                    model.nombreContacto2          = contacto2.NOMBRE;
                    model.apellidoPaternoContacto2 = contacto2.APELLIDO_PATERNO;
                    model.apellidoMaternoContacto2 = contacto2.APELLIDO_MATERNO;
                    model.correoContacto2          = contacto2.EMAIL;
                    model.telefonoContacto2        = contacto2.TELEFONO;
                }

                //datos de direccion
                var direccion = entity.direccion;
                if (direccion != null)
                {
                    model.calle       = direccion.CALLE;
                    model.numExterior = direccion.NUM_EXTERIOR;
                    model.numInterior = direccion.NUM_INTERIOR;
                    model.colonia     = direccion.COLONIA;
                    model.ciudad      = direccion.CIUDAD;
                    model.municipio   = direccion.MUNICIPIO;
                    model.estado      = direccion.ID_ESTADO;
                    model.pais        = direccion.ID_PAIS;
                    model.paisList    = PaisDAO.GetAlls(db);
                    model.estadoList  = direccion.ID_PAIS != null?EstadoDAO.GetByIdPais((int)direccion.ID_PAIS, db) : EstadoDAO.GetAlls(db);

                    model.codigoPostal = direccion.CP;
                }
            }
            catch (Exception e)
            {
                LogUtil.ExceptionLog(e);
                model = null;
            }
        }
コード例 #21
0
 public IActionResult GetSortBys()
 {
     return(Ok(ExtensionMethods.GetKeyValuePairsFromEnum <SortBys>()));
 }
コード例 #22
0
 /// <summary>
 /// Collider for selection with the mouse. Fill with vertices from TunnelData-form.
 /// </summary>
 public static void InitMouseCollider()
 {
     MeshRef.inst.mouseColllider.points = ExtensionMethods.Vector3ToVector2(TunnelData.vertices);
     MeshUpdate.SetMouseColliderSize(VisualController.inst.mouseColliderSize_play);
 }
コード例 #23
0
 public IActionResult GetCategories()
 {
     return(Ok(ExtensionMethods.GetKeyValuePairsFromEnum <Categories>()));
 }
コード例 #24
0
 public void Should_match_overlapping_types()
 {
     Assert.IsTrue(ExtensionMethods.AreMatchingSimpleTypes("string", "String"));
     Assert.IsTrue(ExtensionMethods.AreMatchingSimpleTypes("string", "Token"));
 }
コード例 #25
0
        private StringBuilder WriteOutputToDatabaseOracle(List <Row> rows)
        {
            _Job.PerformanceCounter.Start(_Job.JobIdentifier, JobPerformanceTaskNames.OutputWriterOracle);

            ExtensionMethods.TraceInformation("Starting oracle bulk insert...");
            IDal          dal        = new DataAccessLayer(DatabaseTypes.Oracle).Instance;
            IDbConnection connection = dal.CreateConnection(ConnectionStringKey.Value);

            connection.Open();
            IDbCommand command = dal.CreateCommand();

            command.GetType().GetProperty("ArrayBindCount").SetValue(command, rows.Count, null);
            command.Connection = connection;
            ExtensionMethods.TraceInformation("Communication objects initialized. Creating arrays...");

            int counter = 0;
            //creating arrays & insert statement
            string insertStatementPart1 = string.Format("insert into {0} (", DatabaseMap.TargetTableName);
            string insertStatementPart2 = "values (";

            foreach (ColumnMapInfo columnMapInfo in DatabaseMap)
            {
                if ((!string.IsNullOrEmpty(columnMapInfo.InputColumn)) &&
                    (columnMapInfo.InputColumn != ColumnMapInfo.DatabaseDefault))
                {
                    counter++;

                    insertStatementPart1 += "\"" + columnMapInfo.OutputColumn + "\",";

                    if (columnMapInfo.InputColumn == ColumnMapInfo.CustomDefined)
                    {
                        insertStatementPart2 += string.Format("\"Customer_Id_Seq\".nextval,", counter);
                        continue;
                    }
                    else
                    {
                        insertStatementPart2 += string.Format(":{0},", counter);
                    }

                    SreAttribute attributeAvailable = _Job.DataSource.AcceptableAttributesSystem.Where(a => a.Name == columnMapInfo.InputColumn).SingleOrDefault();
                    if (attributeAvailable == null)
                    {
                        continue;
                    }

                    Type attributeType = attributeAvailable.ConvertSreTypeIntoDotNetType(DatabaseTypes.Oracle);

                    string[] strList = rows.Select(row => GetAttributeValue(row.ColumnsSystem[columnMapInfo.InputColumn], true)).ToArray();

                    if (attributeType == typeof(int))
                    {
                        List <int?> list = strList.Select(s => s.GetValueOrNull <int>()).ToList();
                        command.AddParameterWithValue(columnMapInfo.OutputColumn, list.ToArray(), true);
                    }
                    else if (attributeType == typeof(long))
                    {
                        List <long?> list = strList.Select(s => s.GetValueOrNull <long>()).ToList();
                        command.AddParameterWithValue(columnMapInfo.OutputColumn, list.ToArray(), true);
                    }
                    else if (attributeType == typeof(double))
                    {
                        List <double?> list = strList.Select(s => s.GetValueOrNull <double>()).ToList();
                        command.AddParameterWithValue(columnMapInfo.OutputColumn, list.ToArray(), true);
                    }
                    else if (attributeType == typeof(bool))
                    {
                        List <bool?> list = strList.Select(s => s.GetValueOrNull <bool>()).ToList();
                        command.AddParameterWithValue(columnMapInfo.OutputColumn, list.ToArray(), true);
                    }
                    else if (attributeType == typeof(DateTime))
                    {
                        List <DateTime?> list = strList.Select(s => s.GetValueOrNull <DateTime>()).ToList();
                        command.AddParameterWithValue(columnMapInfo.OutputColumn, list.ToArray(), true);
                    }
                    else
                    {
                        command.AddParameterWithValue(columnMapInfo.OutputColumn, strList, true);
                    }
                }
            }

            if (insertStatementPart1.Length > 1)
            {
                insertStatementPart1 = insertStatementPart1.Substring(0, insertStatementPart1.Length - 1);
            }
            if (insertStatementPart2.Length > 1)
            {
                insertStatementPart2 = insertStatementPart2.Substring(0, insertStatementPart2.Length - 1);
            }

            command.CommandText = string.Format("{0}) {1})", insertStatementPart1, insertStatementPart2);
            ExtensionMethods.TraceInformation("Arrays created. Executing statement - '{0}'", command.CommandText);
            command.ExecuteNonQuery();

            connection.Close();
            connection.Dispose();

            ExtensionMethods.TraceInformation("Oracle bulk insert finished.");
            Trace.Flush();
            _Job.PerformanceCounter.Stop(_Job.JobIdentifier, JobPerformanceTaskNames.OutputWriterOracle);

            return(new StringBuilder());
        }
コード例 #26
0
 public void Should_not_match_simple_to_complex_types()
 {
     Assert.IsFalse(ExtensionMethods.AreMatchingSimpleTypes("string", "ComplexType"));
 }
コード例 #27
0
        /// <summary>Retrieve multiple attributes by web id or path.</summary>
        public ApiResponsePIItemsItemAttribute GetMultipleWithHttpInfo(bool asParallel, string includeMode = null, string paths = null, string selectedFields = null, string webIds = null)
        {
            List <string> path  = ExtensionMethods.ConvertToList(paths);
            List <string> webId = ExtensionMethods.ConvertToList(webIds);

            if (string.IsNullOrEmpty(includeMode) == true)
            {
                includeMode = null;
            }
            if (string.IsNullOrEmpty(selectedFields) == true)
            {
                selectedFields = null;
            }

            var    localVarPath         = "/attributes/multiple";
            var    localVarPathParams   = new Dictionary <String, String>();
            var    localVarQueryParams  = new CustomDictionaryForQueryString();
            var    localVarHeaderParams = new Dictionary <String, String>(Configuration.DefaultHeader);
            var    localVarFormParams   = new Dictionary <String, String>();
            var    localVarFileParams   = new Dictionary <String, FileParameter>();
            Object localVarPostBody     = null;

            String[] localVarHttpContentTypes = new String[] { };
            String   localVarHttpContentType  = Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes);

            String[] localVarHttpHeaderAccepts = new String[] { "application/json", "text/json", "text/xml" };
            String   localVarHttpHeaderAccept  = Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts);

            if (localVarHttpHeaderAccept != null)
            {
                localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept);
            }

            localVarPathParams.Add("format", "json");

            localVarQueryParams.Add("asParallel", Configuration.ApiClient.ParameterToString(asParallel));
            if (includeMode != null)
            {
                localVarQueryParams.Add("includeMode", Configuration.ApiClient.ParameterToString(includeMode));
            }
            localVarQueryParams.Add("path", Configuration.ApiClient.ParameterToString(path));
            if (selectedFields != null)
            {
                localVarQueryParams.Add("selectedFields", Configuration.ApiClient.ParameterToString(selectedFields));
            }
            localVarQueryParams.Add("webId", Configuration.ApiClient.ParameterToString(webId));

            IRestResponse localVarResponse = (IRestResponse)Configuration.ApiClient.CallApi(localVarPath,
                                                                                            Method.GET, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams,
                                                                                            localVarPathParams, localVarHttpContentType);

            int localVarStatusCode = (int)localVarResponse.StatusCode;

            if (ExceptionFactory != null)
            {
                Exception exception = ExceptionFactory("GetMultiple", localVarResponse);
                if (exception != null)
                {
                    throw exception;
                }
            }

            return(new ApiResponsePIItemsItemAttribute(localVarStatusCode,
                                                       localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()),
                                                       (PIItemsItemAttribute)Configuration.ApiClient.Deserialize(localVarResponse, typeof(PIItemsItemAttribute))));
        }
コード例 #28
0
    void Update()
    {
        if (startGame)
        {
            Game();
        }
        if (!startGame)
        {
            UpdateTexts();
            UpdateIcons();

            collectedItems         = 0;
            healthCollectableItems = 0;
            coinCollectableItems   = 0;
            coinItemsAtStart       = 0;

            disableSun        = false;
            minutesTime       = 0;
            secondsTime       = 0;
            scoreNum          = 0;
            currentScoreCount = 0;
            timerCount        = 0;
            health            = 100;
            gameOver          = "idle";

            //ScoreBoardPanel.SetActive(true);

            //if (GameObject.Find("Canvas").GetComponent<ScoreLeaderboard>().currentPlayerIcon != null && (Input.GetButton ("PS4_Options") || Input.GetButton ("360_Start") || Input.GetKeyDown ("space"))) {

            //	currentPlayer = GameObject.Find ("Canvas/ScoreBoardPanel/SelectedPlayer").GetComponent<Text> ().text;

            ScoreBoardPanel.SetActive(false);
            GameObject.Find("Craft").GetComponent <CharacterMovement>().enabled = true;

            startGame = true;

            //print ("select object is active");
            //}
        }

        if (Input.GetKeyDown("3") || Input.GetButton("PS4_Square") || Input.GetButton("360_X") || Input.GetButton("360PC_X"))
        {
            Color rand = ExtensionMethods.RandomColor();
            interfaceColor = rand;
        }
        if (Input.GetKeyDown("4") || Input.GetButton("PS4_Triangle") || Input.GetButton("360_Y") || Input.GetButton("360PC_Y"))
        {
            Color skyRand = ExtensionMethods.RandomColor();

            if (Camera.main.gameObject != null)
            {
                Camera.main.gameObject.GetComponent <Skybox> ().topColor = skyRand;
                Camera.main.gameObject.GetComponent <Skybox> ().midColor = skyRand;
            }
        }
        if (Input.GetKeyDown("5") || Input.GetButton("PS4_O") || Input.GetButton("360_B") || Input.GetButton("360PC_B"))
        {
            Color buildingsRand = ExtensionMethods.RandomColor();
            GameObject.Find("City").GetComponent <GenerateCity> ().buildingsTopColor = buildingsRand;
        }
        if (Input.GetKeyDown("6") || Input.GetButton("PS4_X") || Input.GetButton("360_A") || Input.GetButton("360_A"))
        {
            Color bottomRand = ExtensionMethods.RandomColor();
            Camera.main.gameObject.GetComponent <Skybox> ().bottomColor = bottomRand;
        }


        //print (startGame);
    }
コード例 #29
0
 public frmPaymentToSupplier()
 {
     InitializeComponent();
     ExtensionMethods.SetFormProperties(this);
     applicationFacade = new ApplicationFacade(ExtensionMethods.LoggedInUser);
 }
コード例 #30
0
    /// <summary>
    /// Get the adjacent field ID to a given ID.
    /// </summary>
    public static int NextFieldID(int curID, int direction)
    {
        int nextID = ExtensionMethods.Modulo(curID + direction, TunnelData.FieldsCount);

        return(nextID);
    }
コード例 #31
0
        private void Grid_CellNextlAction()
        {
            int    rowIndex   = dgvPaymentToSupplier.CurrentRow.Index;
            string columnName = dgvPaymentToSupplier.Columns[dgvPaymentToSupplier.SelectedCells[0].ColumnIndex].Name;

            if (columnName == "LedgerTypeCode")
            {
                if (string.IsNullOrEmpty(Convert.ToString(dgvPaymentToSupplier.CurrentCell.Value)))
                {
                    frmSupplierLedger formSupplierLedgerMaster = new frmSupplierLedger();
                    formSupplierLedgerMaster.IsInChildMode = true;
                    //Set Child UI
                    ExtensionMethods.AddChildFormToPanel(this, formSupplierLedgerMaster, ExtensionMethods.MainPanel);
                    formSupplierLedgerMaster.WindowState = FormWindowState.Maximized;

                    formSupplierLedgerMaster.FormClosed += FormSupplierLedgerMaster_FormClosed;
                    formSupplierLedgerMaster.Show();
                }
                else
                {
                    dgvPaymentToSupplier.CurrentCell = dgvPaymentToSupplier.Rows[rowIndex].Cells["ChequeNumber"];
                }
            }
            else if (columnName == "LedgerTypeName")
            {
                dgvPaymentToSupplier.CurrentCell = dgvPaymentToSupplier.Rows[rowIndex].Cells["ChequeNumber"];
            }
            else if (columnName == "ChequeNumber")
            {
                if (String.IsNullOrWhiteSpace(Convert.ToString(dgvPaymentToSupplier.CurrentCell.Value)))
                {
                    dgvPaymentToSupplier.CurrentCell.Value = Constants.PaymentMode.CASHTEXT;
                    dgvPaymentToSupplier.Rows[rowIndex].Cells["PaymentMode"].Value = Constants.PaymentMode.CASH;
                    dgvPaymentToSupplier.CurrentCell = dgvPaymentToSupplier.Rows[rowIndex].Cells["Amount"];
                }
                else
                {
                    if (Convert.ToString(dgvPaymentToSupplier.CurrentCell.Value).Length > 10)
                    {
                        dgvPaymentToSupplier.CurrentCell.ErrorText = Constants.Messages.InValidCheque;
                    }
                    else
                    {
                        dgvPaymentToSupplier.CurrentCell.ErrorText = string.Empty;
                        dgvPaymentToSupplier.Rows[rowIndex].Cells["PaymentMode"].Value = Constants.PaymentMode.CHEQUE;
                        dgvPaymentToSupplier.CurrentCell = dgvPaymentToSupplier.Rows[rowIndex].Cells["ChequeDate"];
                    }
                }
            }
            else if (columnName == "ChequeDate")
            {
                string chequeDate = Convert.ToString(dgvPaymentToSupplier.Rows[rowIndex].Cells["ChequeDate"].Value);
                if (ExtensionMethods.IsValidDate(chequeDate))
                {
                    dgvPaymentToSupplier.CurrentCell = dgvPaymentToSupplier.Rows[rowIndex].Cells["Amount"];
                    dgvPaymentToSupplier.CurrentRow.Cells["ChequeDate"].ErrorText = String.Empty;
                }
                else
                {
                    dgvPaymentToSupplier.CurrentCell = dgvPaymentToSupplier.Rows[rowIndex].Cells["ChequeDate"];
                    dgvPaymentToSupplier.CurrentRow.Cells["ChequeDate"].ErrorText = Constants.Messages.InValidDate;
                }
            }
            else if (columnName == "Amount")
            {
                RaisePaymentModeCalculations();

                decimal enteredAmount    = ExtensionMethods.SafeConversionDecimal(Convert.ToString(dgvPaymentToSupplier.CurrentRow.Cells["Amount"].Value)) ?? default(decimal);
                decimal unadjustedAmount = ExtensionMethods.SafeConversionDecimal(Convert.ToString(dgvPaymentToSupplier.CurrentRow.Cells["UnadjustedAmount"].Value)) ?? default(decimal);
                decimal consumedAmount   = ExtensionMethods.SafeConversionDecimal(Convert.ToString(dgvPaymentToSupplier.CurrentRow.Cells["ConsumedAmount"].Value)) ?? default(decimal);

                if (enteredAmount != 0)
                {
                    frmReceiptPaymentAdjustment formReceiptPaymentAdjustment = new frmReceiptPaymentAdjustment(rowIndex);
                    TransactionEntity           transactionEntity            = new TransactionEntity()
                    {
                        ReceiptPaymentID  = (long)dgvPaymentToSupplier.CurrentRow.Cells["ReceiptPaymentID"].Value,
                        EntityType        = Constants.TransactionEntityType.SupplierLedger,
                        EntityCode        = Convert.ToString(dgvPaymentToSupplier.CurrentRow.Cells["LedgerTypeCode"].Value),
                        EntityName        = Convert.ToString(dgvPaymentToSupplier.CurrentRow.Cells["LedgerTypeName"].Value),
                        EntityTotalAmount = enteredAmount,
                        EntityBalAmount   = enteredAmount - consumedAmount
                    };

                    formReceiptPaymentAdjustment.ConfigureReceiptPaymentAdjustment(transactionEntity);
                    formReceiptPaymentAdjustment.FormClosed += FormReceiptPaymentAdjustment_FormClosed;
                    formReceiptPaymentAdjustment.Show();
                }

                dgvPaymentToSupplier.CurrentCell = dgvPaymentToSupplier.Rows[rowIndex].Cells["Amount"];
            }
            //else if (columnName == "UnadjustedAmount")
            //{
            //    AddNewRowToGrid();

            //    if (!IsInEditMode)
            //    {
            //        dgvSupplierBillOS.DataSource = null;
            //        dgvSupplierBillAdjusted.DataSource = null;
            //        lblAmtOSVal.Text = String.Empty;
            //        lblAmtAdjVal.Text = String.Empty;

            //        dgvPaymentToSupplier.CurrentCell = dgvPaymentToSupplier.Rows[rowIndex + 1].Cells["LedgerTypeCode"];
            //        // dgvPaymentToSupplier.BeginEdit(true);
            //    }
            //}
        }
コード例 #32
0
        private void UpdateReceiptPaymentRow(ReceiptPaymentItem receiptPayment)
        {
            int rowIndex = -1;
            int colIndex = -1;

            if (dgvPaymentToSupplier.SelectedCells.Count > 0)
            {
                rowIndex = dgvPaymentToSupplier.SelectedCells[0].RowIndex;
                colIndex = dgvPaymentToSupplier.SelectedCells[0].ColumnIndex;
                receiptPayment.ReceiptPaymentID = applicationFacade.InsertUpdateTempReceiptPayment(receiptPayment);

                dgvPaymentToSupplier.Rows[rowIndex].Cells["ReceiptPaymentID"].Value          = receiptPayment.ReceiptPaymentID;
                dgvPaymentToSupplier.Rows[rowIndex].Cells["LedgerTypeCode"].Value            = receiptPayment.LedgerTypeCode;
                dgvPaymentToSupplier.Rows[rowIndex].Cells["LedgerTypeName"].Value            = receiptPayment.LedgerTypeName;
                dgvPaymentToSupplier.Rows[rowIndex].Cells["PaymentMode"].Value               = receiptPayment.PaymentMode;
                dgvPaymentToSupplier.Rows[rowIndex].Cells["ChequeNumber"].Value              = receiptPayment.ChequeNumber;
                dgvPaymentToSupplier.Rows[rowIndex].Cells["BankAccountLedgerTypeName"].Value = receiptPayment.BankAccountLedgerTypeName;
                dgvPaymentToSupplier.Rows[rowIndex].Cells["BankAccountLedgerTypeCode"].Value = receiptPayment.BankAccountLedgerTypeCode;
                dgvPaymentToSupplier.Rows[rowIndex].Cells["ChequeDate"].Value          = receiptPayment.ChequeDate == null ? String.Empty : ExtensionMethods.ConvertToAppDateFormat((DateTime)receiptPayment.ChequeDate);
                dgvPaymentToSupplier.Rows[rowIndex].Cells["Amount"].Value              = receiptPayment.Amount;
                dgvPaymentToSupplier.Rows[rowIndex].Cells["ConsumedAmount"].Value      = receiptPayment.Amount - receiptPayment.UnadjustedAmount;
                dgvPaymentToSupplier.Rows[rowIndex].Cells["UnadjustedAmount"].Value    = receiptPayment.UnadjustedAmount;
                dgvPaymentToSupplier.Rows[rowIndex].Cells["OldReceiptPaymentID"].Value = receiptPayment.OldReceiptPaymentID;
            }
        }
コード例 #33
0
    public void DriftCheck()
    {
        //Drift
        if (Input.GetButtonUp("Jump") && drifting)
        {
            drifting   = false;
            driftPower = 0;
        }

        if (Input.GetButtonDown("Jump") && !drifting && Input.GetAxis("Horizontal") != 0)
        {
            drifting       = true;
            driftDirection = Input.GetAxis("Horizontal") > 0 ? 1 : -1;
        }

        if (drifting)
        {
            AddDriftPoints();
            brakeLights.enabled = true;
            if (!sparksPlaying)
            {
                foreach (ParticleSystem i in sparks)
                {
                    if (!i.isPlaying)
                    {
                        i.Play();
                    }
                }
                sparksPlaying = true;
            }


            float tempControl;
            if (driftDirection == 1)
            {
                tempControl = ExtensionMethods.Remap(Input.GetAxis("Horizontal"), -1, 1, -1, 2);
                anim.SetBool("DriftR", true);
            }
            else
            {
                anim.SetBool("DriftL", true);
                tempControl = ExtensionMethods.Remap(Input.GetAxis("Horizontal"), -1, 1, 2, -1);
            }

            float tempPowerControl;
            if (driftDirection == 1)
            {
                tempPowerControl = ExtensionMethods.Remap(Input.GetAxis("Horizontal"), -1, 1, .2f, 1);
            }
            else
            {
                tempPowerControl = ExtensionMethods.Remap(Input.GetAxis("Horizontal"), -1, 1, 1, .2f);
            }
            Brake();
            Steer(driftDirection, tempControl);
            driftPower += tempPowerControl;
        }
        else
        {
            if (Input.GetAxisRaw("LeftTrigger") == 0)
            {
                brakeLights.enabled = false;
            }
            anim.SetBool("DriftR", false);
            anim.SetBool("DriftL", false);

            if (sparksPlaying)
            {
                foreach (ParticleSystem i in sparks)
                {
                    if (i.isPlaying)
                    {
                        i.Stop();
                    }
                }
                sparksPlaying = false;
            }
        }
    }