Exemplo n.º 1
0
        /// <summary>
        /// 根据月份统计
        /// </summary>
        /// <param name="time"></param>
        /// <returns></returns>
        private DataTable GetData_Month(DateTime time)
        {
            DataTable dt = new DataTable();

            dt.Columns.Add("Count", typeof(int));       //个数
            dt.Columns.Add("Date", typeof(string));     //日期

            DataRow dr;

            try
            {
                Service.IService.IMobilePhone service = new Service.ServiceImp.MobilePhone();
                var firstDay = Convert.ToDateTime(time.Year + "-" + time.Month + "-01");
                var lastDay  = Convert.ToDateTime(Convert.ToDateTime(time.AddMonths(1).ToString("yyyy-MM-01")).AddDays(-1).ToString("yyyy-MM-dd 23:59"));
                var list     = service.LoadListAll(p => p.MobileOutTime >= firstDay && p.MobileOutTime < lastDay);

                for (int i = 1; i <= DateTime.DaysInMonth(time.Year, time.Month); i++)
                {
                    dr = dt.NewRow();

                    dr["Date"]  = Convert.ToDateTime(time.Year + "-" + time.Month + "-" + i).ToString("yyyy-MM-dd");
                    dr["Count"] = list.Where(p => p.MobileOutTime >= Convert.ToDateTime(dr["Date"].ToString()) && p.MobileOutTime < Convert.ToDateTime(dr["Date"].ToString() + " 23:59")).ToList().Count;
                    dt.Rows.Add(dr);
                }
            }
            catch (Exception)
            {
                throw;
            }


            return(dt);
        }
Exemplo n.º 2
0
        private void  除ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                int id = Convert.ToInt32(gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "ID"));

                if (DialogResult.OK == XtraMessageBox.Show("您确定将该条记录删除吗?", "操作", MessageBoxButtons.OKCancel))
                {
                    Service.IService.IMobilePhone service = new Service.ServiceImp.MobilePhone();
                    var model = service.Get(p => p.ID == id);
                    model.MobileState         = 0;            //修改出库状态为入库
                    model.MobileOutTime       = null;         //修改出库时间
                    model.MobileSales         = null;         //出库金额为0
                    model.MobileSalesPersonId = null;         //修改销售员
                    model.MobileOutRemarks    = string.Empty; //修改出库备注为空
                    model.MobileProfit        = null;         //利润

                    if (service.Update(model))
                    {
                        XtraMessageBox.Show("删除成功!");
                        OutStorageManage_Load(null, null);
                    }
                    else
                    {
                        XtraMessageBox.Show("删除失败!");
                    }
                }
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show("删除出错!" + ex.Message);
            }
        }
Exemplo n.º 3
0
        private void InitDataById(int id)
        {
            try
            {
                if (id <= 0)
                {
                    return;
                }

                Service.IService.IMobilePhone phone = new Service.ServiceImp.MobilePhone();
                var model = phone.Get(p => p.ID == id);

                lue_Brand.EditValue    = model.MobileBrandId;                                                                                                                              //品牌ID
                lue_Type.EditValue     = model.MobileModelId;                                                                                                                              //型号ID
                txt_IMEI.Text          = model.MobileIMEI;                                                                                                                                 //串码
                txt_Cost.Text          = model.MobileCost.ToString();                                                                                                                      //成本
                lue_Supplier.EditValue = model.MobileSupplierId;                                                                                                                           //供应商
                txt_Remarks.Text       = model.MobileRemarks;                                                                                                                              //备注
                txt_IntoDate.Text      = model.MobileInTime == null?DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss") : Convert.ToDateTime(model.MobileInTime).ToString("yyyy/MM/dd HH:mm:ss"); //入库时间
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show("根据ID加载数据出错!" + ex.Message);
            }
        }
Exemplo n.º 4
0
        private void InitDataById(int id)
        {
            try
            {
                Service.IService.IMobilePhone service = new Service.ServiceImp.MobilePhone();
                var model = service.Get(p => p.ID == id);
                btn_Select.Text   = model.MobileIMEI;                                                                                                                                          //串码
                lbl_Brand.Text    = model.MobileBrand.PROPNAME;                                                                                                                                //品牌
                lbl_Type.Text     = model.MobileModel.PROPNAME;                                                                                                                                //型号
                lbl_Supplier.Text = model.MobileSupplier.PROPNAME;                                                                                                                             //供应商
                lbl_Cost.Text     = model.MobileCost.ToString();                                                                                                                               //成本

                txt_Remarks.Text         = model.MobileOutRemarks;                                                                                                                             //备注
                lue_SalePerson.EditValue = model.MobileSalesPersonId;                                                                                                                          //销售员
                txt_Sales.Text           = model.MobileSales.ToString();                                                                                                                       //出库金额
                txt_OutDate.Text         = model.MobileOutTime == null?DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss") : Convert.ToDateTime(model.MobileOutTime).ToString("yyyy/MM/dd HH:mm:ss"); //出库时间
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show("加载数据出错!" + ex.Message);
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// 根据年份统计
        /// </summary>
        /// <param name="time"></param>
        /// <returns></returns>
        private DataTable GetData_Year(DateTime time)
        {
            DataTable dt = new DataTable();

            dt.Columns.Add("Count", typeof(int));       //个数
            dt.Columns.Add("Brand", typeof(string));    //品牌

            DataRow dr;

            try
            {
                Service.IService.IMobilePhone  service = new Service.ServiceImp.MobilePhone();
                Service.IService.IPropTypeBase prop    = new Service.ServiceImp.PropTypeBase();

                var firstMonth = Convert.ToDateTime(time.Year + "-01-01");
                var lastMonth  = Convert.ToDateTime(Convert.ToDateTime(time.Year + "-12-31").ToString("yyyy-MM-dd 23:59"));

                var list = service.LoadListAll(p => p.MobileOutTime >= firstMonth && p.MobileOutTime < lastMonth);

                var brand = prop.LoadListAll(p => p.PROPPARENT == 2);       //获取所有品牌

                foreach (var b in brand)
                {
                    dr = dt.NewRow();

                    dr["Brand"] = b.PROPNAME;
                    dr["Count"] = list.Where(p => p.MobileBrandId == b.PROPID).Where(p => p.MobileOutTime >= firstMonth && p.MobileOutTime < lastMonth).ToList().Count;
                    dt.Rows.Add(dr);
                }
            }
            catch (Exception)
            {
                throw;
            }


            return(dt);
        }
Exemplo n.º 6
0
 private void  除ToolStripMenuItem_Click(object sender, EventArgs e)
 {
     try
     {
         int id = Convert.ToInt32(gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "ID"));
         if (DialogResult.OK == XtraMessageBox.Show("您确定将该条记录删除吗?", "操作", MessageBoxButtons.OKCancel))
         {
             Service.IService.IMobilePhone service = new Service.ServiceImp.MobilePhone();
             if (service.Delete(p => p.ID == id) > 0)
             {
                 XtraMessageBox.Show("删除成功!");
                 IntoStorageManage_Load(null, null);
             }
             else
             {
                 XtraMessageBox.Show("删除失败!");
             }
         }
     }
     catch (Exception ex)
     {
         XtraMessageBox.Show("删除异常!" + ex.Message);
     }
 }
Exemplo n.º 7
0
        private void btn_Save_Click(object sender, EventArgs e)
        {
            try
            {
                if (SelectId <= 0 || string.IsNullOrEmpty(btn_Select.Text.Trim()))
                {
                    XtraMessageBox.Show("请您选择串号!");
                    return;
                }

                if (string.IsNullOrEmpty(lue_SalePerson.Text) || lue_SalePerson.Text == "请选择")
                {
                    XtraMessageBox.Show("请您选择销售员!");
                    return;
                }

                if (string.IsNullOrEmpty(txt_Sales.Text.Trim()))
                {
                    XtraMessageBox.Show("请您填写出库金额!");
                    return;
                }
                else
                {
                    if (!Common.Tools.IsNumber(txt_Sales.Text.Trim()))
                    {
                        XtraMessageBox.Show("出库金额格式不正确!");
                        return;
                    }
                }

                if (string.IsNullOrEmpty(txt_OutDate.Text.Trim()))
                {
                    XtraMessageBox.Show("出库时间不能为空!");
                    return;
                }
                else
                {
                    if (!Common.Tools.IsDate(txt_OutDate.Text.Trim()))
                    {
                        XtraMessageBox.Show("出库时间格式不正确!");
                        return;
                    }
                }

                Service.IService.IMobilePhone service = new Service.ServiceImp.MobilePhone();
                var model = service.Get(p => p.ID == SelectId);

                model.MobileSales         = Convert.ToDecimal(txt_Sales.Text.Trim());  //出库金额
                model.MobileSalesPersonId = Convert.ToInt32(lue_SalePerson.EditValue); //销售员
                //如果有出库时间,则不修改出库时间
                model.MobileOutTime    = Convert.ToDateTime(txt_OutDate.Text.Trim());
                model.MobileState      = 1;
                model.MobileProfit     = model.MobileSales - model.MobileCost; //利润
                model.MobileOutRemarks = txt_Remarks.Text.Trim();              //备注

                if (service.Update(model))
                {
                    DialogResult = DialogResult.OK;
                    XtraMessageBox.Show("保存成功!");
                    this.Close();
                }
                else
                {
                    XtraMessageBox.Show("保存失败!");
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemplo n.º 8
0
        private void btn_Save_Click(object sender, EventArgs e)
        {
            try
            {
                if (string.IsNullOrEmpty(lue_Brand.Text) || lue_Brand.Text == "请选择")
                {
                    XtraMessageBox.Show("请您选择品牌!");
                    return;
                }

                if (string.IsNullOrEmpty(lue_Type.Text) || lue_Type.Text == "请选择")
                {
                    XtraMessageBox.Show("请您选择型号!");
                    return;
                }

                if (string.IsNullOrEmpty(lue_Supplier.Text) || lue_Supplier.Text == "请选择")
                {
                    XtraMessageBox.Show("请您选择供应商!");
                    return;
                }

                if (string.IsNullOrEmpty(txt_IMEI.Text.Trim()))
                {
                    XtraMessageBox.Show("请您填写串号!");
                    return;
                }

                if (string.IsNullOrEmpty(txt_Cost.Text.Trim()))
                {
                    XtraMessageBox.Show("请您填写金额!");
                    return;
                }
                else
                {
                    if (!Common.Tools.IsNumber(txt_Cost.Text.Trim()))
                    {
                        XtraMessageBox.Show("金额格式不正确!");
                        return;
                    }
                }

                if (string.IsNullOrEmpty(txt_IntoDate.Text.Trim()))
                {
                    XtraMessageBox.Show("入库时间不能为空!");
                    return;
                }
                else
                {
                    if (!Common.Tools.IsDate(txt_IntoDate.Text.Trim()))
                    {
                        XtraMessageBox.Show("入库时间格式不正确!");
                        return;
                    }
                }



                Service.IService.IMobilePhone phone  = new Service.ServiceImp.MobilePhone();
                Domain.MobilePhone            mobile = new Domain.MobilePhone();

                if (Id <= 0)
                {
                    //保存
                    if (phone.IsExist(p => p.MobileIMEI == txt_IMEI.Text.Trim()))
                    {
                        XtraMessageBox.Show("该串码已经存在!");
                        return;
                    }
                }
                else
                {
                    mobile = phone.Get(p => p.ID == Id);

                    if (mobile.MobileIMEI != txt_IMEI.Text.Trim() && phone.IsExist(p => p.MobileIMEI == txt_IMEI.Text.Trim()))
                    {
                        XtraMessageBox.Show("该串码已经存在!");
                        return;
                    }
                }

                mobile.MobileBrandId    = Convert.ToInt32(lue_Brand.EditValue);    //品牌ID
                mobile.MobileModelId    = Convert.ToInt32(lue_Type.EditValue);     //型号ID
                mobile.MobileIMEI       = txt_IMEI.Text.Trim();                    //串码
                mobile.MobileCost       = Convert.ToDecimal(txt_Cost.Text.Trim()); //成本
                mobile.MobileSupplierId = Convert.ToInt32(lue_Supplier.EditValue); //供应商
                mobile.MobileInTime     = Convert.ToDateTime(txt_IntoDate.Text.Trim());
                mobile.MobileState      = 0;                                       //0 表示未出库
                mobile.MobileRemarks    = txt_Remarks.Text.Trim();                 //备注

                if (phone.SaveOrUpdate(mobile, Id > 0))
                {
                    XtraMessageBox.Show("保存成功!");
                    DialogResult = DialogResult.OK;
                    this.Close();
                }
                else
                {
                    XtraMessageBox.Show("保存失败!");
                }
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show("保存失败!" + ex.Message);
            }
        }