/// <summary>
        /// List all detected cloud storages
        /// </summary>
        public static List <StorageStatus> DetectCloudStorage()
        {
            List <StorageStatus> cloudstorages = new List <StorageStatus>();

            if (DropboxHelper.IsInstalled())
            {
                // currently only support one driver
                Model.Driver       driver       = Model.DriverCollection.Instance.FindOne();
                Model.CloudStorage cloudstorage = Model.CloudStorageCollection.Instance.FindOne(Query.EQ("Type", "dropbox"));
                if (cloudstorage != null)
                {
                    cloudstorages.Add(new StorageStatus
                    {
                        type      = "dropbox",
                        connected = true,
                        quota     = cloudstorage.Quota,
                        used      = new DropboxFileStorage(driver, cloudstorage).GetUsedSize()
                    }
                                      );
                }
                else
                {
                    cloudstorages.Add(new StorageStatus
                    {
                        type      = "dropbox",
                        connected = false
                    }
                                      );
                }
            }

            return(cloudstorages);
        }
        private async Task DeleteDriver(Context context, Model.Driver entity, CancellationToken cancellationToken)
        {
            var driver = await context.Drivers.FirstOrDefaultAsync(q => q.Id == entity.Id, cancellationToken);

            context.Drivers.Remove(driver);
            await context.SaveChangesAsync(cancellationToken);
        }
Exemple #3
0
        private bool DoAdd()
        {
            bool result = false;
            Model.Driver model = new Model.Driver();
            BLL.Driver bll = new BLL.Driver();

            model.CarNumber = ddlCarNumber.SelectedValue;
            model.RealName = txtRealName.Text.Trim();
            model.RealNameCode = txtRealNameCode.Text.Trim();
            model.IdCardNumber = txtIdCardNumber.Text.Trim();
            model.LinkTel = txtLinkTel.Text.Trim();
            model.LinkAddress = txtLinkAddress.Text.Trim();
            model.BeganWorkDate = Utils.StrToDateTime(txtBeganWorkDate.Text.Trim());
            model.IssuedDate = Utils.StrToDateTime(txtIssuedDate.Text.Trim());
            model.AnnualDate = Utils.StrToDateTime(txtAnnualDate.Text.Trim());
            model.DrivingLicence = txtDrivingLicence.Text.Trim();
            model.DrivingPermitNumber = txtDrivingPermitNumber.Text.Trim();
            model.DrivingPermitType = txtDrivingPermitType.Text.Trim();
            model.IsDimission = chkIsDimission.Checked ? 1 : 0;
            model.Remarks = txtRemarks.Text.Trim();

            if (bll.Add(model) > 0)
            {
                AddAdminLog(DTEnums.ActionEnum.Add.ToString(), "添加司机:" + model.RealName); //记录日志
                result = true;
            }
            return result;
        }
        public static void RemoveOwner(string userId)
        {
            try
            {
                Model.Driver driver = Model.DriverCollection.Instance.FindOne(Query.EQ("_id", userId));
                if (driver == null)
                {
                    throw new UserDoesNotExistException("driver " + userId + " does not exist");
                }


                CloudServer.request <CloudResponse>(
                    new WebClient(),
                    StationMgmtURL + "station/drivers/remove",
                    new Dictionary <object, object>
                {
                    { CloudServer.PARAM_API_KEY, CloudServer.APIKey },
                    { CloudServer.PARAM_SESSION_TOKEN, driver.session_token },
                    { CloudServer.PARAM_USER_ID, userId },
                }
                    );
            }
            catch (WammerCloudException e)
            {
                ExtractApiRetMsg(e);

                throw;
            }
        }
Exemple #5
0
        private bool DoAdd()
        {
            bool result = false;

            Model.Driver model = new Model.Driver();
            BLL.Driver   bll   = new BLL.Driver();

            model.CarNumber           = ddlCarNumber.SelectedValue;
            model.RealName            = txtRealName.Text.Trim();
            model.RealNameCode        = txtRealNameCode.Text.Trim();
            model.IdCardNumber        = txtIdCardNumber.Text.Trim();
            model.LinkTel             = txtLinkTel.Text.Trim();
            model.LinkAddress         = txtLinkAddress.Text.Trim();
            model.BeganWorkDate       = Utils.StrToDateTime(txtBeganWorkDate.Text.Trim());
            model.IssuedDate          = Utils.StrToDateTime(txtIssuedDate.Text.Trim());
            model.AnnualDate          = Utils.StrToDateTime(txtAnnualDate.Text.Trim());
            model.DrivingLicence      = txtDrivingLicence.Text.Trim();
            model.DrivingPermitNumber = txtDrivingPermitNumber.Text.Trim();
            model.DrivingPermitType   = txtDrivingPermitType.Text.Trim();
            model.IsDimission         = chkIsDimission.Checked ? 1 : 0;
            model.Remarks             = txtRemarks.Text.Trim();

            if (bll.Add(model) > 0)
            {
                AddAdminLog(DTEnums.ActionEnum.Add.ToString(), "添加司机:" + model.RealName); //记录日志
                result = true;
            }
            return(result);
        }
Exemple #6
0
 /// <summary>
 /// Fires the strategy modified event after a strategy has been modified
 /// </summary>
 public static void OnStrategyModified(Model.Driver driver, Model.Strategy strategy, bool showAllOnGraph)
 {
     if (StrategyModified != null)
     {
         StrategyModified(driver.DriverIndex, strategy, showAllOnGraph);
     }
 }
Exemple #7
0
        public bool Update(SqlConnection conn, SqlTransaction trans, Model.Driver model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update mtms_Driver set ");

            strSql.Append(" RealName = @RealName , ");
            strSql.Append(" RealNameCode = @RealNameCode , ");
            strSql.Append(" CarNumber = @CarNumber , ");
            strSql.Append(" IdCardNumber = @IdCardNumber , ");
            strSql.Append(" LinkTel = @LinkTel , ");
            strSql.Append(" LinkAddress = @LinkAddress , ");
            strSql.Append(" BeganWorkDate = @BeganWorkDate , ");
            strSql.Append(" IssuedDate = @IssuedDate , ");
            strSql.Append(" AnnualDate = @AnnualDate , ");
            strSql.Append(" DrivingLicence = @DrivingLicence , ");
            strSql.Append(" DrivingPermitNumber = @DrivingPermitNumber , ");
            strSql.Append(" DrivingPermitType = @DrivingPermitType , ");
            strSql.Append(" IsDimission = @IsDimission , ");
            strSql.Append(" Remarks = @Remarks  ");
            strSql.Append(" where Id=@Id ");

            SqlParameter[] parameters =
            {
                new SqlParameter("@Id",                  SqlDbType.Int,         4),
                new SqlParameter("@RealName",            SqlDbType.VarChar,   254),
                new SqlParameter("@RealNameCode",        SqlDbType.VarChar,   254),
                new SqlParameter("@CarNumber",           SqlDbType.VarChar,   254),
                new SqlParameter("@IdCardNumber",        SqlDbType.VarChar,   254),
                new SqlParameter("@LinkTel",             SqlDbType.VarChar,   254),
                new SqlParameter("@LinkAddress",         SqlDbType.VarChar,   254),
                new SqlParameter("@BeganWorkDate",       SqlDbType.DateTime),
                new SqlParameter("@IssuedDate",          SqlDbType.DateTime),
                new SqlParameter("@AnnualDate",          SqlDbType.DateTime),
                new SqlParameter("@DrivingLicence",      SqlDbType.VarChar,   254),
                new SqlParameter("@DrivingPermitNumber", SqlDbType.VarChar,   254),
                new SqlParameter("@DrivingPermitType",   SqlDbType.VarChar,   254),
                new SqlParameter("@IsDimission",         SqlDbType.SmallInt,    2),
                new SqlParameter("@Remarks",             SqlDbType.VarChar, 254)
            };

            parameters[0].Value  = model.Id;
            parameters[1].Value  = model.RealName;
            parameters[2].Value  = model.RealNameCode;
            parameters[3].Value  = model.CarNumber;
            parameters[4].Value  = model.IdCardNumber;
            parameters[5].Value  = model.LinkTel;
            parameters[6].Value  = model.LinkAddress;
            parameters[7].Value  = model.BeganWorkDate;
            parameters[8].Value  = model.IssuedDate;
            parameters[9].Value  = model.AnnualDate;
            parameters[10].Value = model.DrivingLicence;
            parameters[11].Value = model.DrivingPermitNumber;
            parameters[12].Value = model.DrivingPermitType;
            parameters[13].Value = model.IsDimission;
            parameters[14].Value = model.Remarks;

            return(DbHelperSQL.ExecuteSql(conn, trans, strSql.ToString(), parameters) > 0);
        }
Exemple #8
0
        public bool Add(Model.Vehicle model, Model.Driver driver)
        {
            using (SqlConnection conn = new SqlConnection(DbHelperSQL.connectionString))
            {
                conn.Open();
                using (SqlTransaction trans = conn.BeginTransaction())
                {
                    try
                    {
                        StringBuilder strSql = new StringBuilder();
                        strSql.Append("insert into mtms_Vehicle(");
                        strSql.Append("CarCode,CarNumber,MotorcadeName,MotorcycleType,LoadingCapacity,EngineType,FrameNumber,ChassisNumber,InsuranceNumber,Remarks");
                        strSql.Append(") values (");
                        strSql.Append("@CarCode,@CarNumber,@MotorcadeName,@MotorcycleType,@LoadingCapacity,@EngineType,@FrameNumber,@ChassisNumber,@InsuranceNumber,@Remarks");
                        strSql.Append(") ");
                        strSql.Append(";select @@IDENTITY");
                        SqlParameter[] parameters =
                        {
                            new SqlParameter("@CarCode",         SqlDbType.VarChar, 254),
                            new SqlParameter("@CarNumber",       SqlDbType.VarChar, 254),
                            new SqlParameter("@MotorcadeName",   SqlDbType.VarChar, 254),
                            new SqlParameter("@MotorcycleType",  SqlDbType.VarChar, 254),
                            new SqlParameter("@LoadingCapacity", SqlDbType.Decimal,   9),
                            new SqlParameter("@EngineType",      SqlDbType.VarChar, 254),
                            new SqlParameter("@FrameNumber",     SqlDbType.VarChar, 254),
                            new SqlParameter("@ChassisNumber",   SqlDbType.VarChar, 254),
                            new SqlParameter("@InsuranceNumber", SqlDbType.VarChar, 254),
                            new SqlParameter("@Remarks",         SqlDbType.VarChar, 254)
                        };

                        parameters[0].Value = model.CarCode;
                        parameters[1].Value = model.CarNumber;
                        parameters[2].Value = model.MotorcadeName;
                        parameters[3].Value = model.MotorcycleType;
                        parameters[4].Value = model.LoadingCapacity;
                        parameters[5].Value = model.EngineType;
                        parameters[6].Value = model.FrameNumber;
                        parameters[7].Value = model.ChassisNumber;
                        parameters[8].Value = model.InsuranceNumber;
                        parameters[9].Value = model.Remarks;

                        DbHelperSQL.ExecuteSql(conn, trans, strSql.ToString(), parameters);

                        new Driver().Add(conn, trans, driver);

                        trans.Commit();
                    }
                    catch
                    {
                        trans.Rollback();
                        return(false);
                    }
                }
            }

            return(true);
        }
Exemple #9
0
        public Model.Driver GetModel(string carNumber)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select top 1 Id, RealName, RealNameCode, CarNumber, IdCardNumber, LinkTel, LinkAddress, BeganWorkDate, IssuedDate, AnnualDate, DrivingLicence, DrivingPermitNumber, DrivingPermitType, IsDimission, Remarks  ");
            strSql.Append("  from mtms_Driver ");
            strSql.Append(" where CarNumber=@CarNumber");
            SqlParameter[] parameters =
            {
                new SqlParameter("@CarNumber", SqlDbType.VarChar, 254)
            };
            parameters[0].Value = carNumber;


            Model.Driver model = new Model.Driver();
            DataSet      ds    = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["Id"].ToString() != "")
                {
                    model.Id = int.Parse(ds.Tables[0].Rows[0]["Id"].ToString());
                }
                model.RealName     = ds.Tables[0].Rows[0]["RealName"].ToString();
                model.RealNameCode = ds.Tables[0].Rows[0]["RealNameCode"].ToString();
                model.CarNumber    = ds.Tables[0].Rows[0]["CarNumber"].ToString();
                model.IdCardNumber = ds.Tables[0].Rows[0]["IdCardNumber"].ToString();
                model.LinkTel      = ds.Tables[0].Rows[0]["LinkTel"].ToString();
                model.LinkAddress  = ds.Tables[0].Rows[0]["LinkAddress"].ToString();
                if (ds.Tables[0].Rows[0]["BeganWorkDate"].ToString() != "")
                {
                    model.BeganWorkDate = DateTime.Parse(ds.Tables[0].Rows[0]["BeganWorkDate"].ToString());
                }
                if (ds.Tables[0].Rows[0]["IssuedDate"].ToString() != "")
                {
                    model.IssuedDate = DateTime.Parse(ds.Tables[0].Rows[0]["IssuedDate"].ToString());
                }
                if (ds.Tables[0].Rows[0]["AnnualDate"].ToString() != "")
                {
                    model.AnnualDate = DateTime.Parse(ds.Tables[0].Rows[0]["AnnualDate"].ToString());
                }
                model.DrivingLicence      = ds.Tables[0].Rows[0]["DrivingLicence"].ToString();
                model.DrivingPermitNumber = ds.Tables[0].Rows[0]["DrivingPermitNumber"].ToString();
                model.DrivingPermitType   = ds.Tables[0].Rows[0]["DrivingPermitType"].ToString();
                if (ds.Tables[0].Rows[0]["IsDimission"].ToString() != "")
                {
                    model.IsDimission = int.Parse(ds.Tables[0].Rows[0]["IsDimission"].ToString());
                }
                model.Remarks = ds.Tables[0].Rows[0]["Remarks"].ToString();

                return(model);
            }
            else
            {
                return(null);
            }
        }
        /// <summary>
        /// Gets default folder to save attachments
        /// </summary>
        /// <remarks>If the owner of station is not set yet, null is returned.</remarks>
        /// <returns></returns>
        public static string GetDefaultFolder()
        {
            Model.Driver driver = Model.DriverCollection.Instance.FindOne();
            if (driver == null)
            {
                return(null);
            }

            return(driver.folder);
        }
        /// <summary>
        /// Gets owner's email
        /// </summary>
        /// <returns>Owner's email. If owner is not set yet, null is returned.</returns>
        public static string GetOwner()
        {
            Model.Driver driver = Model.DriverCollection.Instance.FindOne();
            if (driver == null)
            {
                return(null);
            }

            return(driver.email);
        }
Exemple #12
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Model.Driver model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into mtms_Driver(");
            strSql.Append("RealName,RealNameCode,CarNumber,IdCardNumber,LinkTel,LinkAddress,BeganWorkDate,IssuedDate,AnnualDate,DrivingLicence,DrivingPermitNumber,DrivingPermitType,IsDimission,Remarks");
            strSql.Append(") values (");
            strSql.Append("@RealName,@RealNameCode,@CarNumber,@IdCardNumber,@LinkTel,@LinkAddress,@BeganWorkDate,@IssuedDate,@AnnualDate,@DrivingLicence,@DrivingPermitNumber,@DrivingPermitType,@IsDimission,@Remarks");
            strSql.Append(") ");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@RealName",            SqlDbType.VarChar,   254),
                new SqlParameter("@RealNameCode",        SqlDbType.VarChar,   254),
                new SqlParameter("@CarNumber",           SqlDbType.VarChar,   254),
                new SqlParameter("@IdCardNumber",        SqlDbType.VarChar,   254),
                new SqlParameter("@LinkTel",             SqlDbType.VarChar,   254),
                new SqlParameter("@LinkAddress",         SqlDbType.VarChar,   254),
                new SqlParameter("@BeganWorkDate",       SqlDbType.DateTime),
                new SqlParameter("@IssuedDate",          SqlDbType.DateTime),
                new SqlParameter("@AnnualDate",          SqlDbType.DateTime),
                new SqlParameter("@DrivingLicence",      SqlDbType.VarChar,   254),
                new SqlParameter("@DrivingPermitNumber", SqlDbType.VarChar,   254),
                new SqlParameter("@DrivingPermitType",   SqlDbType.VarChar,   254),
                new SqlParameter("@IsDimission",         SqlDbType.SmallInt,    2),
                new SqlParameter("@Remarks",             SqlDbType.VarChar, 254)
            };

            parameters[0].Value  = model.RealName;
            parameters[1].Value  = model.RealNameCode;
            parameters[2].Value  = model.CarNumber;
            parameters[3].Value  = model.IdCardNumber;
            parameters[4].Value  = model.LinkTel;
            parameters[5].Value  = model.LinkAddress;
            parameters[6].Value  = model.BeganWorkDate;
            parameters[7].Value  = model.IssuedDate;
            parameters[8].Value  = model.AnnualDate;
            parameters[9].Value  = model.DrivingLicence;
            parameters[10].Value = model.DrivingPermitNumber;
            parameters[11].Value = model.DrivingPermitType;
            parameters[12].Value = model.IsDimission;
            parameters[13].Value = model.Remarks;

            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
        private static void SetDefaultFolder(string absPath)
        {
            Model.Driver driver = Model.DriverCollection.Instance.FindOne();
            if (driver == null)
            {
                throw new InvalidOperationException("Cannot set default folder before driver is not set yet.");
            }

            driver.folder = absPath;
            Model.DriverCollection.Instance.Save(driver);
        }
        public static Data.Entities.Driver ConvertToEntity(this Model.Driver model)
        {
            var driver = new Data.Entities.Driver
            {
                FirstName = model.FirstName,
                LastName  = model.LastName,
                ShortName = model.ShortName,
                PlayerId  = model.PlayerId
            };

            return(driver);
        }
Exemple #15
0
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List <Model.Driver> DataTableToList(DataTable dt)
        {
            List <Model.Driver> modelList = new List <Model.Driver>();
            int rowsCount = dt.Rows.Count;

            if (rowsCount > 0)
            {
                Model.Driver model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new Model.Driver();
                    if (dt.Rows[n]["Id"].ToString() != "")
                    {
                        model.Id = int.Parse(dt.Rows[n]["Id"].ToString());
                    }
                    model.RealName     = dt.Rows[n]["RealName"].ToString();
                    model.RealNameCode = dt.Rows[n]["RealNameCode"].ToString();
                    model.CarNumber    = dt.Rows[n]["CarNumber"].ToString();
                    model.IdCardNumber = dt.Rows[n]["IdCardNumber"].ToString();
                    model.LinkTel      = dt.Rows[n]["LinkTel"].ToString();
                    model.LinkAddress  = dt.Rows[n]["LinkAddress"].ToString();
                    if (dt.Rows[n]["BeganWorkDate"].ToString() != "")
                    {
                        model.BeganWorkDate = DateTime.Parse(dt.Rows[n]["BeganWorkDate"].ToString());
                    }
                    if (dt.Rows[n]["IssuedDate"].ToString() != "")
                    {
                        model.IssuedDate = DateTime.Parse(dt.Rows[n]["IssuedDate"].ToString());
                    }
                    if (dt.Rows[n]["AnnualDate"].ToString() != "")
                    {
                        model.AnnualDate = DateTime.Parse(dt.Rows[n]["AnnualDate"].ToString());
                    }
                    model.DrivingLicence      = dt.Rows[n]["DrivingLicence"].ToString();
                    model.DrivingPermitNumber = dt.Rows[n]["DrivingPermitNumber"].ToString();
                    model.DrivingPermitType   = dt.Rows[n]["DrivingPermitType"].ToString();
                    if (dt.Rows[n]["IsDimission"].ToString() != "")
                    {
                        model.IsDimission = int.Parse(dt.Rows[n]["IsDimission"].ToString());
                    }
                    model.Remarks = dt.Rows[n]["Remarks"].ToString();


                    modelList.Add(model);
                }
            }
            return(modelList);
        }
Exemple #16
0
        private void ShowInfo(int _id)
        {
            BLL.Vehicle   bll   = new BLL.Vehicle();
            Model.Vehicle model = bll.GetModel(_id);
            if (model != null)
            {
                txtCarCode.Text = model.CarCode;

                BLL.Driver   driverBLL = new BLL.Driver();
                Model.Driver driver    = driverBLL.GetModel(model.CarCode);
                if (driver != null)
                {
                    txtRealName.Text = driver.RealName;
                    txtLinkTel.Text  = driver.LinkTel;
                }
            }
        }
Exemple #17
0
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List<Model.Driver> DataTableToList(DataTable dt)
        {
            List<Model.Driver> modelList = new List<Model.Driver>();
            int rowsCount = dt.Rows.Count;
            if (rowsCount > 0)
            {
                Model.Driver model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new Model.Driver();
                    if (dt.Rows[n]["Id"].ToString() != "")
                    {
                        model.Id = int.Parse(dt.Rows[n]["Id"].ToString());
                    }
                    model.RealName = dt.Rows[n]["RealName"].ToString();
                    model.RealNameCode = dt.Rows[n]["RealNameCode"].ToString();
                    model.CarNumber = dt.Rows[n]["CarNumber"].ToString();
                    model.IdCardNumber = dt.Rows[n]["IdCardNumber"].ToString();
                    model.LinkTel = dt.Rows[n]["LinkTel"].ToString();
                    model.LinkAddress = dt.Rows[n]["LinkAddress"].ToString();
                    if (dt.Rows[n]["BeganWorkDate"].ToString() != "")
                    {
                        model.BeganWorkDate = DateTime.Parse(dt.Rows[n]["BeganWorkDate"].ToString());
                    }
                    if (dt.Rows[n]["IssuedDate"].ToString() != "")
                    {
                        model.IssuedDate = DateTime.Parse(dt.Rows[n]["IssuedDate"].ToString());
                    }
                    if (dt.Rows[n]["AnnualDate"].ToString() != "")
                    {
                        model.AnnualDate = DateTime.Parse(dt.Rows[n]["AnnualDate"].ToString());
                    }
                    model.DrivingLicence = dt.Rows[n]["DrivingLicence"].ToString();
                    model.DrivingPermitNumber = dt.Rows[n]["DrivingPermitNumber"].ToString();
                    model.DrivingPermitType = dt.Rows[n]["DrivingPermitType"].ToString();
                    if (dt.Rows[n]["IsDimission"].ToString() != "")
                    {
                        model.IsDimission = int.Parse(dt.Rows[n]["IsDimission"].ToString());
                    }
                    model.Remarks = dt.Rows[n]["Remarks"].ToString();

                    modelList.Add(model);
                }
            }
            return modelList;
        }
Exemple #18
0
        private bool DoEdit(int _id)
        {
            bool result = false;

            BLL.Vehicle   bll       = new BLL.Vehicle();
            Model.Vehicle model     = bll.GetModel(_id);
            string        carNumber = model.CarNumber;

            model.MotorcadeName   = "";
            model.CarCode         = txtCarCode.Text.Trim();
            model.CarNumber       = model.CarCode;
            model.MotorcycleType  = "";
            model.EngineType      = "";
            model.ChassisNumber   = "";
            model.FrameNumber     = "";
            model.InsuranceNumber = "";
            model.LoadingCapacity = 0.00M;
            model.Remarks         = "";


            BLL.Driver   driverBll = new BLL.Driver();
            Model.Driver driver    = driverBll.GetModel(carNumber);

            driver.CarNumber           = model.CarNumber;
            driver.RealName            = txtRealName.Text.Trim();
            driver.RealNameCode        = "";
            driver.IdCardNumber        = "";
            driver.LinkTel             = txtLinkTel.Text.Trim();
            driver.LinkAddress         = "";
            driver.BeganWorkDate       = DateTime.Now;
            driver.IssuedDate          = DateTime.Now;
            driver.AnnualDate          = DateTime.Now;
            driver.DrivingLicence      = "";
            driver.DrivingPermitNumber = "";
            driver.DrivingPermitType   = "";
            driver.IsDimission         = 0;
            driver.Remarks             = "";

            if (bll.Update(model, driver))
            {
                AddAdminLog(DTEnums.ActionEnum.Edit.ToString(), "修改车辆信息:" + model.CarCode); //记录日志
                result = true;
            }
            return(result);
        }
Exemple #19
0
        private void ShowInfo(int _id)
        {
            BLL.Driver   bll   = new BLL.Driver();
            Model.Driver model = bll.GetModel(_id);

            ddlCarNumber.SelectedValue  = model.CarNumber;
            txtRealName.Text            = model.RealName;
            txtRealNameCode.Text        = model.RealNameCode;
            txtIdCardNumber.Text        = model.IdCardNumber;
            txtLinkTel.Text             = model.LinkTel;
            txtLinkAddress.Text         = model.LinkAddress;
            txtBeganWorkDate.Text       = model.BeganWorkDate.ToString("yyyy-MM-dd");
            txtIssuedDate.Text          = model.IssuedDate.ToString("yyyy-MM-dd");
            txtAnnualDate.Text          = model.AnnualDate.ToString("yyyy-MM-dd");
            txtDrivingLicence.Text      = model.DrivingLicence;
            txtDrivingPermitNumber.Text = model.DrivingPermitNumber;
            txtDrivingPermitType.Text   = model.DrivingPermitType;
            chkIsDimission.Checked      = (model.IsDimission == 1);
            txtRemarks.Text             = model.Remarks;
        }
Exemple #20
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     if (txtDriverName.Text == String.Empty)
     {
         MessageBox.Show("Please type a Driver name");
     }
     else if (txtDriverCost.Text == String.Empty)
     {
         MessageBox.Show("Please type a Driver Cost per day");
     }
     else
     {
         Model.Driver model = new Model.Driver()
         {
             DriverName = txtDriverName.Text,
             DriverCost = Convert.ToInt32(txtDriverCost.Text)
         };
         db.Drivers.Add(model);
         db.SaveChanges();
         MessageBox.Show("Driver Details Saccessfully Saved");
         this.Close();
     }
 }
Exemple #21
0
 public bool Add(Model.Vehicle model, Model.Driver driver)
 {
     return(dal.Add(model, driver));
 }
Exemple #22
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int Add(Model.Driver model)
 {
     return(dal.Add(model));
 }
Exemple #23
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(Model.Driver model)
 {
     return(dal.Update(model));
 }
Exemple #24
0
        public Model.Driver GetModel(string carNumber)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select Id, RealName, RealNameCode, CarNumber, IdCardNumber, LinkTel, LinkAddress, BeganWorkDate, IssuedDate, AnnualDate, DrivingLicence, DrivingPermitNumber, DrivingPermitType, IsDimission, Remarks  ");
            strSql.Append("  from mtms_Driver ");
            strSql.Append(" where CarNumber=@CarNumber");
            SqlParameter[] parameters = {
                    new SqlParameter("@CarNumber", SqlDbType.VarChar,254)
            };
            parameters[0].Value = carNumber;

            Model.Driver model = new Model.Driver();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["Id"].ToString() != "")
                {
                    model.Id = int.Parse(ds.Tables[0].Rows[0]["Id"].ToString());
                }
                model.RealName = ds.Tables[0].Rows[0]["RealName"].ToString();
                model.RealNameCode = ds.Tables[0].Rows[0]["RealNameCode"].ToString();
                model.CarNumber = ds.Tables[0].Rows[0]["CarNumber"].ToString();
                model.IdCardNumber = ds.Tables[0].Rows[0]["IdCardNumber"].ToString();
                model.LinkTel = ds.Tables[0].Rows[0]["LinkTel"].ToString();
                model.LinkAddress = ds.Tables[0].Rows[0]["LinkAddress"].ToString();
                if (ds.Tables[0].Rows[0]["BeganWorkDate"].ToString() != "")
                {
                    model.BeganWorkDate = DateTime.Parse(ds.Tables[0].Rows[0]["BeganWorkDate"].ToString());
                }
                if (ds.Tables[0].Rows[0]["IssuedDate"].ToString() != "")
                {
                    model.IssuedDate = DateTime.Parse(ds.Tables[0].Rows[0]["IssuedDate"].ToString());
                }
                if (ds.Tables[0].Rows[0]["AnnualDate"].ToString() != "")
                {
                    model.AnnualDate = DateTime.Parse(ds.Tables[0].Rows[0]["AnnualDate"].ToString());
                }
                model.DrivingLicence = ds.Tables[0].Rows[0]["DrivingLicence"].ToString();
                model.DrivingPermitNumber = ds.Tables[0].Rows[0]["DrivingPermitNumber"].ToString();
                model.DrivingPermitType = ds.Tables[0].Rows[0]["DrivingPermitType"].ToString();
                if (ds.Tables[0].Rows[0]["IsDimission"].ToString() != "")
                {
                    model.IsDimission = int.Parse(ds.Tables[0].Rows[0]["IsDimission"].ToString());
                }
                model.Remarks = ds.Tables[0].Rows[0]["Remarks"].ToString();

                return model;
            }
            else
            {
                return null;
            }
        }
Exemple #25
0
        private bool DoAdd()
        {
            bool result = false;
            Model.Vehicle model = new Model.Vehicle();
            BLL.Vehicle bll = new BLL.Vehicle();

            model.MotorcadeName = "";
            model.CarCode = txtCarCode.Text.Trim();
            model.CarNumber = model.CarCode;
            model.MotorcycleType = "";
            model.EngineType = "";
            model.ChassisNumber = "";
            model.FrameNumber = "";
            model.InsuranceNumber = "";
            model.LoadingCapacity = 0.00M;
            model.Remarks = "";

            Model.Driver driver = new Model.Driver();
            BLL.Driver driverBll = new BLL.Driver();

            driver.CarNumber = model.CarNumber;
            driver.RealName = txtRealName.Text.Trim();
            driver.RealNameCode = "";
            driver.IdCardNumber = "";
            driver.LinkTel = txtLinkTel.Text.Trim();
            driver.LinkAddress = "";
            driver.BeganWorkDate = DateTime.Now;
            driver.IssuedDate = DateTime.Now;
            driver.AnnualDate = DateTime.Now;
            driver.DrivingLicence = "";
            driver.DrivingPermitNumber = "";
            driver.DrivingPermitType = "";
            driver.IsDimission = 0;
            driver.Remarks = "";

            if (bll.Add(model, driver))
            {
                AddAdminLog(DTEnums.ActionEnum.Add.ToString(), "添加车辆:" + model.CarCode); //记录日志
                result = true;
            }
            return result;
        }
Exemple #26
0
        public bool Update(Model.Vehicle model, Model.Driver driver)
        {
            using (SqlConnection conn = new SqlConnection(DbHelperSQL.connectionString))
            {
                conn.Open();
                using (SqlTransaction trans = conn.BeginTransaction())
                {
                    try
                    {
                        StringBuilder strSql = new StringBuilder();
                        strSql.Append("update mtms_Vehicle set ");

                        strSql.Append(" CarCode = @CarCode , ");
                        strSql.Append(" CarNumber = @CarNumber , ");
                        strSql.Append(" MotorcadeName = @MotorcadeName , ");
                        strSql.Append(" MotorcycleType = @MotorcycleType , ");
                        strSql.Append(" LoadingCapacity = @LoadingCapacity , ");
                        strSql.Append(" EngineType = @EngineType , ");
                        strSql.Append(" FrameNumber = @FrameNumber , ");
                        strSql.Append(" ChassisNumber = @ChassisNumber , ");
                        strSql.Append(" InsuranceNumber = @InsuranceNumber , ");
                        strSql.Append(" Remarks = @Remarks  ");
                        strSql.Append(" where Id=@Id ");

                        SqlParameter[] parameters =
                        {
                            new SqlParameter("@Id",              SqlDbType.Int,       4),
                            new SqlParameter("@CarCode",         SqlDbType.VarChar, 254),
                            new SqlParameter("@CarNumber",       SqlDbType.VarChar, 254),
                            new SqlParameter("@MotorcadeName",   SqlDbType.VarChar, 254),
                            new SqlParameter("@MotorcycleType",  SqlDbType.VarChar, 254),
                            new SqlParameter("@LoadingCapacity", SqlDbType.Decimal,   9),
                            new SqlParameter("@EngineType",      SqlDbType.VarChar, 254),
                            new SqlParameter("@FrameNumber",     SqlDbType.VarChar, 254),
                            new SqlParameter("@ChassisNumber",   SqlDbType.VarChar, 254),
                            new SqlParameter("@InsuranceNumber", SqlDbType.VarChar, 254),
                            new SqlParameter("@Remarks",         SqlDbType.VarChar, 254)
                        };

                        parameters[0].Value  = model.Id;
                        parameters[1].Value  = model.CarCode;
                        parameters[2].Value  = model.CarNumber;
                        parameters[3].Value  = model.MotorcadeName;
                        parameters[4].Value  = model.MotorcycleType;
                        parameters[5].Value  = model.LoadingCapacity;
                        parameters[6].Value  = model.EngineType;
                        parameters[7].Value  = model.FrameNumber;
                        parameters[8].Value  = model.ChassisNumber;
                        parameters[9].Value  = model.InsuranceNumber;
                        parameters[10].Value = model.Remarks;

                        DbHelperSQL.ExecuteSql(conn, trans, strSql.ToString(), parameters);

                        new Driver().Update(conn, trans, driver);

                        trans.Commit();
                    }
                    catch
                    {
                        trans.Rollback();
                        return(false);
                    }
                }
            }

            return(true);
        }
        private async Task CreateDriver(Context context, Model.Driver Driver, CancellationToken cancellationToken)
        {
            await context.Drivers.AddAsync(Driver, cancellationToken);

            await context.SaveChangesAsync(cancellationToken);
        }
Exemple #28
0
 public bool Update(Model.Vehicle model, Model.Driver driver)
 {
     return(dal.Update(model, driver));
 }
 public void Update(Model.Driver driver)
 {
     _context.Entry(driver).State = EntityState.Modified;
 }
 private async Task UpdateDriver(Context context, Model.Driver newDriver, CancellationToken cancellationToken)
 {
     context.Update(newDriver);
     await context.SaveChangesAsync(cancellationToken);
 }