Esempio n. 1
0
        private bool HasNullPayInfo(PayInfo payInfo)
        {
            if (string.IsNullOrEmpty(payInfo.Name.Trim()))
            {
                return(true);
            }
            if (0 == payInfo.PayDay)
            {
                return(true);
            }
            if (0 == payInfo.BillDay)
            {
                return(true);
            }
            if (0.0 == payInfo.PayLimit)
            {
                return(true);
            }
            if (0.0 == payInfo.CostBase)
            {
                return(true);
            }

            return(false);
        }
Esempio n. 2
0
        private void btPreView_Click(object sender, RoutedEventArgs e)
        {
            if (false == CheckPayInfoOK())
            {
                return;
            }

            SavePayInfo();

            List <PayInfo> listNotNullPayInfo = new List <PayInfo>();

            foreach (object item in dataGridPayInfo.Items)
            {
                if ((item as PayInfo) != null)
                {
                    PayInfo payInfo = item as PayInfo;
                    if (false == HasNullPayInfo(payInfo))
                    {
                        listNotNullPayInfo.Add(payInfo);
                    }
                }
            }
            if (listNotNullPayInfo.Count == 0)
            {
                MessageBox.Show("没有可预览的记录");
                return;
            }



            string        strFailReason = "";
            List <double> listSum       = PreViewHelper.GetSumList(
                Convert.ToInt32(comboPayDayCount.SelectedValue),
                Convert.ToInt32(comboPayMode.SelectedIndex),
                listNotNullPayInfo,
                listCompanyInfo,
                radomHelper,
                ref strFailReason);


            List <double> listCard = new List <double>();

            foreach (PayInfo payInfo in listNotNullPayInfo)
            {
                listCard.Add(payInfo.PayLimit);
            }

            listPreViewInfo             = PreViewHelper.ProductPreViewList(listSum, listCard);
            dataGridPreView.ItemsSource = listPreViewInfo;
        }
Esempio n. 3
0
 private void comboCostBase_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     for (int i = 0; i < dataGridPayInfo.Items.Count; i++)
     {
         if (dataGridPayInfo.Items[i] is PayInfo)
         {
             PayInfo payInfo = (PayInfo)dataGridPayInfo.Items[i];
             if (0.0 != payInfo.CostBase)
             {
                 payInfo.CostBase = Convert.ToDouble(comboCostBase.SelectedValue);
             }
         }
     }
 }
Esempio n. 4
0
        private void dataGridExcel_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (dataGridPayInfo.SelectedItems.Count == 1)
            {
                cbTrunCostExtForSafe.IsChecked = false;

                if ((dataGridPayInfo.SelectedItems[0] as PayInfo) != null)
                {
                    CurrentPayInfo        = dataGridPayInfo.SelectedItems[0] as PayInfo;
                    tbCostExtForSafe.Text = CurrentPayInfo.CostExtForSafe.ToString();
                }
            }
            else
            {
                CurrentPayInfo = null;
            }
        }
Esempio n. 5
0
 private void btClean_Click(object sender, RoutedEventArgs e)
 {
     if (dataGridPayInfo.SelectedItems.Count > 0)
     {
         foreach (object item in dataGridPayInfo.SelectedItems)
         {
             if ((item as PayInfo) != null)
             {
                 PayInfo payInfo = item as PayInfo;
                 payInfo.Name     = "";
                 payInfo.PayDay   = 0;
                 payInfo.BillDay  = 0;
                 payInfo.PayLimit = 0.0;
                 payInfo.CostBase = 0.0;
             }
         }
         SavePayInfo();
     }
     else
     {
         return;
     }
 }
Esempio n. 6
0
        private void SavePayInfo()
        {
            using (StreamWriter SW = new StreamWriter(iniPayFileName))
            {
                string line = null;

                for (int i = 0; i < dataGridPayInfo.Items.Count; i++)
                {
                    if (dataGridPayInfo.Items[i] is PayInfo)
                    {
                        PayInfo  payInfo   = (PayInfo)dataGridPayInfo.Items[i];
                        string[] rgPayInfo = new string[payInfoMemberCount];
                        rgPayInfo[0] = payInfo.Name;
                        rgPayInfo[1] = payInfo.BillDay.ToString();
                        rgPayInfo[2] = payInfo.PayDay.ToString();
                        rgPayInfo[3] = payInfo.PayLimit.ToString();
                        rgPayInfo[4] = payInfo.CostBase.ToString();
                        rgPayInfo[5] = payInfo.CostExtForSafe.ToString();
                        line         = string.Join(",", rgPayInfo);
                        SW.WriteLine(line);
                    }
                }
            }
        }
Esempio n. 7
0
        void initINI()
        {
            #region 公司文件存在
            if (System.IO.File.Exists(iniCompanyFileName) == true)
            {
                using (StreamReader SR = new StreamReader(iniCompanyFileName))
                {
                    string line = null;
                    while ((line = SR.ReadLine()) != null)
                    {
                        string[] pms = line.Split(',');

                        if (pms.Length < companyInfoMemberCount)
                        {
                            break;
                        }

                        CompanyInfo companyInfo = new CompanyInfo();
                        companyInfo.LiveliHood       = pms[0];
                        companyInfo.Normal           = pms[1];
                        companyInfo.HightConsumption = pms[2];

                        listCompanyInfo.Add(companyInfo);

                        if (listCompanyInfo.Count == MaxLineCompanyInfo)
                        {
                            break;
                        }
                    }
                }
            }
            #endregion

            #region 信用卡信息存在
            if (System.IO.File.Exists(iniPayFileName) == true)
            {
                using (StreamReader SR = new StreamReader(iniPayFileName))
                {
                    string line = null;

                    while ((line = SR.ReadLine()) != null)
                    {
                        string[] pms = line.Split(',');

                        if (pms.Length < payInfoMemberCount)
                        {
                            break;
                        }

                        PayInfo payInfo = new PayInfo();
                        payInfo.Name           = pms[0];
                        payInfo.BillDay        = Convert.ToInt32(pms[1]);
                        payInfo.PayDay         = Convert.ToInt32(pms[2]);
                        payInfo.PayLimit       = Convert.ToDouble(pms[3]);
                        payInfo.CostBase       = Convert.ToDouble(pms[4]);
                        payInfo.CostExtForSafe = Convert.ToDouble(pms[5]);

                        listPayInfo.Add(payInfo);

                        if (listPayInfo.Count == MaxLinePayInfo)
                        {
                            break;
                        }
                    }
                }
            }
            #endregion

            #region 补充空行
            while (listPayInfo.Count < MaxLinePayInfo)
            {
                PayInfo payInfo = new PayInfo();
                listPayInfo.Add(payInfo);
            }
            while (listCompanyInfo.Count < MaxLineCompanyInfo)
            {
                CompanyInfo companyInfo = new CompanyInfo();
                listCompanyInfo.Add(companyInfo);
            }
            #endregion
        }
Esempio n. 8
0
        private void dataGridPayInfo_PreviewKeyDown(object sender, KeyEventArgs e)
        {
            if (
                e.Key == Key.V &&
                (Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control
                )
            {
                IDataObject ido = Clipboard.GetDataObject();

                if (ido == null)
                {
                    return;
                }
                string[] formats = ido.GetFormats();
                string   format  = formats[0].ToString();
                object   data    = ido.GetData(format);

                string   strPaste = data.ToString();
                string[] rows     = strPaste.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);

                if (rows.Length <= 0)
                {
                    return;
                }

                int startIndex = dataGridPayInfo.SelectedIndex;
                if (-1 == startIndex)    //未选中
                {
                    return;
                }

                int index = 0;
                for (int i = 0; i < rows.Count(); i++)
                {
                    if (index + startIndex >= MaxLinePayInfo)
                    {
                        return;
                    }

                    string[] rgParam    = rows[i].Split(',');;
                    int      paramCount = 5;
                    if (rgParam.Length != paramCount)
                    {
                        return;
                    }

                    int    billDay  = 0;
                    int    payDay   = 0;
                    double payLimit = 0.0;
                    double costBase = 0.0;


                    bool fBillDay  = int.TryParse(rgParam[1], out billDay);
                    bool fPayDay   = int.TryParse(rgParam[2], out payDay);
                    bool fPayLimit = double.TryParse(rgParam[3], out payLimit);
                    bool fCostBase = double.TryParse(rgParam[4], out costBase);
                    if (
                        fBillDay &&
                        fPayDay &&
                        fPayLimit &&
                        fCostBase
                        )
                    {    //全部可解析
                        if (dataGridPayInfo.Items[index + startIndex] is PayInfo)
                        {
                            int     sub     = index + startIndex;
                            PayInfo payInfo = dataGridPayInfo.Items[sub] as PayInfo;
                            if (null != payInfo)
                            {
                                payInfo.Name     = rgParam[0];
                                payInfo.BillDay  = billDay;
                                payInfo.PayDay   = payDay;
                                payInfo.PayLimit = payLimit;
                                payInfo.CostBase = costBase;
                                index++;
                            }
                        }
                    }
                    else    //部分可解析
                    {
                        if (dataGridPayInfo.Items[index + startIndex] is PayInfo)
                        {
                            int     sub     = index + startIndex;
                            PayInfo payInfo = dataGridPayInfo.Items[sub] as PayInfo;
                            if (null != payInfo)
                            {
                                payInfo.Name     = rgParam[0];
                                payInfo.BillDay  = billDay;
                                payInfo.PayDay   = payDay;
                                payInfo.PayLimit = payLimit;
                                payInfo.CostBase = costBase;
                                index++;
                            }
                        }
                    }
                }
            }
        }
Esempio n. 9
0
        private void btOutPutExcel_Click(object sender, RoutedEventArgs e)
        {
            if (false == CheckPayInfoOK())
            {
                return;
            }

            SavePayInfo();

            List <PayInfo> listNotNullPayInfo = new List <PayInfo>();

            foreach (object item in dataGridPayInfo.Items)
            {
                if ((item as PayInfo) != null)
                {
                    PayInfo payInfo = item as PayInfo;
                    if (false == HasNullPayInfo(payInfo))
                    {
                        listNotNullPayInfo.Add(payInfo);
                    }
                }
            }
            if (listNotNullPayInfo.Count == 0)
            {
                MessageBox.Show("没有可导出的记录");
                return;
            }

            string singleName = @"z整月安排.xls";
            string fullName   = System.IO.Path.Combine(
                Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory),
                singleName);

            int index = 1;

            while (true)
            {
                if (System.IO.File.Exists(fullName) == true)
                {
                    singleName = string.Format("z整月安排{0}.xls", index);
                    fullName   = System.IO.Path.Combine(
                        Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory),
                        singleName);
                    index++;
                }
                else
                {
                    break;
                }
            }

            string strFailReason = "";

            if (ExcelHelper.OutPutExcel(excelTempFieName,
                                        fullName,
                                        Convert.ToInt32(comboPayDayCount.SelectedValue),
                                        Convert.ToInt32(comboPayMode.SelectedIndex),
                                        listNotNullPayInfo,
                                        listCompanyInfo,
                                        radomHelper,
                                        ref strFailReason))
            {
                MessageBox.Show("导出完成");
            }
            else
            {
                MessageBox.Show(string.Format("导出失败。原因为:{0}", strFailReason));
            }
        }
Esempio n. 10
0
        void initINI()
        {
            #region 公司文件存在
            if (System.IO.File.Exists(iniCompanyFileName) == true)
            {
                using (StreamReader SR = new StreamReader(iniCompanyFileName))
                {
                    string line = null;
                    while ((line = SR.ReadLine()) != null)
                    {
                        string[] pms = line.Split(',');

                        if (pms.Length < companyInfoMemberCount)
                        {
                            break;
                        }

                        CompanyInfo companyInfo = new CompanyInfo();
                        companyInfo.LiveliHood = pms[0];
                        companyInfo.Normal = pms[1];
                        companyInfo.HightConsumption = pms[2];

                        listCompanyInfo.Add(companyInfo);

                        if (listCompanyInfo.Count == MaxLineCompanyInfo)
                        {
                            break;
                        }
                    }
                }
            }
            #endregion

            #region 信用卡信息存在
            if (System.IO.File.Exists(iniPayFileName) == true)
            {
                using (StreamReader SR = new StreamReader(iniPayFileName))
                {
                    string line = null;

                    while ((line = SR.ReadLine()) != null)
                    {
                        string[] pms = line.Split(',');

                        if (pms.Length < payInfoMemberCount)
                        {
                            break;
                        }

                        PayInfo payInfo = new PayInfo();
                        payInfo.Name = pms[0];
                        payInfo.BillDay = Convert.ToInt32(pms[1]);
                        payInfo.PayDay = Convert.ToInt32(pms[2]);
                        payInfo.PayLimit = Convert.ToDouble(pms[3]);
                        payInfo.CostBase = Convert.ToDouble(pms[4]);
                        payInfo.CostExtForSafe = Convert.ToDouble(pms[5]);

                        listPayInfo.Add(payInfo);

                        if (listPayInfo.Count == MaxLinePayInfo)
                        {
                            break;
                        }
                    }
                }
            }
            #endregion

            #region 补充空行
            while (listPayInfo.Count < MaxLinePayInfo)
            {
                PayInfo payInfo = new PayInfo();
                listPayInfo.Add(payInfo);
            }
            while (listCompanyInfo.Count < MaxLineCompanyInfo)
            {
                CompanyInfo companyInfo = new CompanyInfo();
                listCompanyInfo.Add(companyInfo);
            }
            #endregion
        }
Esempio n. 11
0
        private bool HasNullPayInfo(PayInfo payInfo)
        {
            if (string.IsNullOrEmpty(payInfo.Name.Trim()))
            {
                return true;
            }
            if (0 == payInfo.PayDay)
            {
                return true;
            }
            if (0 == payInfo.BillDay)
            {
                return true;
            }
            if (0.0 == payInfo.PayLimit)
            {
                return true;
            }
            if (0.0 == payInfo.CostBase)
            {
                return true;
            }

            return false;
        }
Esempio n. 12
0
        private void dataGridExcel_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (dataGridPayInfo.SelectedItems.Count == 1)
            {
                cbTrunCostExtForSafe.IsChecked = false;

                if ((dataGridPayInfo.SelectedItems[0] as PayInfo) != null)
                {
                    CurrentPayInfo = dataGridPayInfo.SelectedItems[0] as PayInfo;
                    tbCostExtForSafe.Text = CurrentPayInfo.CostExtForSafe.ToString();
                }
            }
            else
            {
                CurrentPayInfo = null;
            }
        }