コード例 #1
0
        protected override void ExecItemRefresh()
        {
            string EmpTag     = "0";
            string EmpNo      = "";
            string DepartTag  = "0";
            string DepartID   = "";
            string DepartList = "";
            string ResultYM   = dtpStart.Value.ToString(SystemInfo.YMFormatDB);

            if ((txtEmp.Text.Trim() != "") && (txtEmp.Tag != null))
            {
                EmpNo  = txtEmp.Tag.ToString();
                EmpTag = "1";
            }
            else if (txtEmp.Text.Trim() != "")
            {
                EmpNo = txtEmp.Text.Trim();
            }
            if ((txtDepart.Text.Trim() != "") && (txtDepart.Tag != null))
            {
                DepartID  = txtDepart.Tag.ToString();
                DepartTag = "1";
                if (DepartID != "")
                {
                    DepartList = SystemInfo.db.GetDepartChildID(DepartID);
                }
                if (DepartList == "")
                {
                    DepartList = "''";
                }
            }
            else if (txtDepart.Text.Trim() != "")
            {
                DepartID = txtDepart.Text.Trim();
            }
            long days = Pub.DateDiff(DateInterval.Day, dtpStart.Value.Date, dtpEnd.Value.Date) + 1;

            if (days > 31)
            {
                Pub.MessageBoxShow(string.Format(Pub.GetResText(formCode, "Error001", ""), 31));
                return;
            }
            CalcRecords(EmpTag, EmpNo, DepartTag, DepartID, DepartList, ResultYM);
            QuerySQL = Pub.GetSQL(DBCode.DB_000215, new string[] { "1", EmpTag, EmpNo, DepartTag, DepartID, DepartList, ResultYM });
            System.Threading.Thread.Sleep(1000);
            base.ExecItemRefresh();
            SetReportTitle(dispView, this.Text);
        }
コード例 #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            frmKQHolidayAddA frm = new frmKQHolidayAddA(button1.Text, HolidayTimeList, HoliDayOtTypeList);

            if (frm.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            DateTime  d    = frm.StartDate;
            int       days = (int)Pub.DateDiff(DateInterval.Day, d, frm.EndDate);
            DataTable dt   = (DataTable)dataGrid.DataSource;

            for (int i = 0; i <= days; i++)
            {
                DataRow da = dt.NewRow();
                da["HolidayDate"]   = d.AddDays(i);
                da["HolidayDName"]  = frm.HoliName;
                da["HolidayTime"]   = frm.HoliTime;
                da["HoliDayOtType"] = frm.OtType;
                dt.Rows.Add(da);
            }
            RefreshButton();
        }
コード例 #3
0
ファイル: RSEmpCardFa.cs プロジェクト: huanghengrui/ECardSoft
        private void FaCard(bool IsBatch, string Oprt)
        {
            frmAppMain frm = Pub.GetAppMainForm();

            if (SystemInfo.CardKey == "")
            {
                Pub.ShowErrorMsg(Pub.GetResText(formCode, "ErrorCardkey", ""));
                if (frm != null)
                {
                    frm.ExecModule("SYOption", "");
                }
                return;
            }
            if (SystemInfo.DealersCode == "")
            {
                Pub.ShowErrorMsg(Pub.GetResText(formCode, "ErrorDealersCode", ""));
                if (frm != null)
                {
                    frm.ExecModule("SYOption", "");
                }
                return;
            }
            if (SystemInfo.CustomersCode == 0)
            {
                Pub.ShowErrorMsg(Pub.GetResText(formCode, "ErrorCustomersCode", ""));
                if (frm != null)
                {
                    frm.ExecModule("SYOption", "");
                }
                return;
            }
            if (!DeviceObject.objCPIC.IsOnline())
            {
                lblMsg.Text = Pub.GetResText(formCode, "ReadCardError1", "");
                return;
            }
            DateTime d   = new DateTime();
            DateTime Fad = new DateTime();

            if (!db.GetServerDate(ref d))
            {
                return;
            }
            Fad = d;
            if (Pub.MessageBoxShowQuestion(string.Format(Pub.GetResText(formCode, "MsgServerDate", ""), d)))
            {
                return;
            }
            double DepositMoney = 0;

            double.TryParse(CurrencyToStringEx(ItemMoneyText.Text), out DepositMoney);
            if (DepositMoney < 0)
            {
                DepositMoney = 0.00;
            }
            DataTable dt = (DataTable)bindingSource.DataSource;
            DataRow   dr = null;

            IsFaCard = true;
            RefreshForm(true);
            string   EmpSysID        = "";
            string   CardSectorNo    = "";
            int      CardStatusID    = 0;
            string   msg             = "";
            int      DepositDiscount = 0;
            int      UseTimes        = 0;
            int      reStatus        = 0;
            DateTime CardStartDate   = new DateTime();
            DateTime CardEndDate     = new DateTime();
            bool     IsFirst         = true;
            long     CardDays        = 0;
            string   CardPWD         = "";
            string   EmpNo           = "";
            string   EmpName         = "";
            byte     CardTypeID      = 0;
            double   CardStored      = 0.00;
            double   DiscountM       = 0.00;
            bool     CardCheckOrder  = false;
            string   CardNoDays      = "";
            int      cardRet         = 0;
            string   CardData10;
            string   CardDataH;
            string   CardData8;
            string   CardNo10;
            string   CardNoH;
            string   CardNo8;
            string   UseEmpNo         = "";
            string   ErrMsg           = "";
            double   CardFee          = 0;
            bool     IsLock           = false;
            string   LockOprtNo       = "";
            string   LockComputerName = "";
            int      currRow          = bindingSource.Position;
            string   MacTAG           = DeviceObject.objCPIC.GetMacTAG();

            HSUNFK.TCardPubData pubData = new HSUNFK.TCardPubData();
            HSUNFK.TCardSFData  sfData  = new HSUNFK.TCardSFData();
            HSUNFK.TCardSKData  skData  = new HSUNFK.TCardSKData();
            bool IsError     = false;
            bool IsValidCard = false;

            while (IsFaCard)
            {
                for (int i = currRow; i < dt.Rows.Count; i++)
                {
AgainCard:
                    bindingSource.Position = i;
                    dataGrid.CurrentCell   = dataGrid.SelectedRows[0].Cells[0];
                    Application.DoEvents();
                    dr       = dt.Rows[i];
                    EmpSysID = dr["EmpSysID"].ToString();
                    if (!db.EmpGetCardStatusIDByEmpSysID(EmpSysID, ref CardStatusID, ref IsLock, ref LockOprtNo, ref LockComputerName))
                    {
                        continue;
                    }
                    if (IsLock || ((CardStatusID != 10) && (CardStatusID != 60)))
                    {
                        continue;
                    }
                    CardSectorNo  = dr["CardSectorNo"].ToString();
                    CardStartDate = (DateTime)dr["CardStartDate"];
                    CardEndDate   = (DateTime)dr["CardEndDate"];
                    CardPWD       = dr["CardPWD"].ToString();
                    if ((CardPWD == "") || (!Pub.IsNumeric(CardPWD)))
                    {
                        CardPWD = "000000";
                    }
                    if (Convert.ToInt32(CardPWD) > 999999)
                    {
                        CardPWD = "000000";
                    }
                    EmpNo           = dr["EmpNo"].ToString();
                    EmpName         = dr["EmpName"].ToString();
                    CardTypeID      = Convert.ToByte(dr["CardTypeID"]);
                    DepositDiscount = 0;

                    if (!dr.IsNull("DepositDiscount"))
                    {
                        DepositDiscount = Convert.ToInt32(dr["DepositDiscount"].ToString());
                    }
                    CardFee = 0;
                    if (!dr.IsNull("CardFee"))
                    {
                        CardFee = Convert.ToDouble(dr["CardFee"].ToString());
                    }
                    UseTimes = 0;
                    if (!dr.IsNull("CardUseTimes"))
                    {
                        UseTimes = Convert.ToInt32(dr["CardUseTimes"].ToString());
                    }
                    CardStored = 0.00;
                    if (!dr.IsNull("CardStored"))
                    {
                        CardStored = Convert.ToDouble(dr["CardStored"]);
                    }
                    if (!IsBatch && (DepositMoney > 0))
                    {
                        CardStored = DepositMoney;
                        if (SystemInfo.FaCardFee)
                        {
                            CardStored -= CardFee;
                        }
                        if (CardStored < 0)
                        {
                            CardFee    = 0;
                            CardStored = 0;
                        }
                    }
                    DiscountM = CardStored;
                    double tmpMoney = 0;
                    byte   discFlag = db.GetDiscDiscount(CardStored, CardTypeID, ref tmpMoney);
                    if (discFlag == 2)
                    {
                        break;
                    }
                    if (discFlag == 1)
                    {
                        DiscountM = DiscountM + tmpMoney;
                    }
                    else if (DepositDiscount > 0)
                    {
                        DiscountM = CardStored * DepositDiscount / 100;
                    }
                    CardCheckOrder = false;
                    if (!dr.IsNull("CardCheckOrder"))
                    {
                        CardCheckOrder = Pub.ValueToBool(dr["CardCheckOrder"]);
                    }
                    if (IsFirst)
                    {
                        IsFirst  = false;
                        CardDays = Pub.DateDiff(DateInterval.Day, CardStartDate, CardEndDate);
                        if (CardDays <= 30)
                        {
                            msg = Pub.GetResText(formCode, "MsgCardDaySmall", "");
                            msg = string.Format(msg, CardDays);
                            if (Pub.MessageBoxShowQuestion(msg))
                            {
                                ItemStop_Click(null, null);
                                return;
                            }
                        }
                    }

                    if (SystemInfo.AllowCustomerCardNo)
                    {
                        if ((CardSectorNo == "") || (!Pub.IsNumeric(CardSectorNo)))
                        {
                            CardSectorNo = db.GetMaxCardSectorNo(EmpSysID);
                            if (CardSectorNo == "")
                            {
                                Pub.ShowErrorMsg(Pub.GetResText(formCode, "ErrorBuildCardFailed", ""));
                                ItemStop_Click(null, null);
                                return;
                            }
                        }
                        else if ((CardStatusID == 60) && db.CardSectorNoIsExists(EmpSysID, CardSectorNo, ref CardNoDays))
                        {
                            if (CardNoDays == " ")
                            {
                                msg = Pub.GetResText(formCode, "MsgCardExistsBlack", "");
                            }
                            else if (DateTime.TryParse(CardNoDays, out d))
                            {
                                msg = Pub.GetResText(formCode, "MsgCardExistsUseDays", "");
                            }
                            else
                            {
                                msg = Pub.GetResText(formCode, "MsgCardExistsUseing", "");
                            }
                            msg = string.Format(msg, CardSectorNo, CardNoDays);
                            if (Pub.MessageBoxShowQuestion(msg))
                            {
                                ItemStop_Click(null, null);
                                return;
                            }
                            CardSectorNo = db.GetMaxCardSectorNo(EmpSysID);
                            if (CardSectorNo == "")
                            {
                                Pub.ShowErrorMsg(Pub.GetResText(formCode, "ErrorBuildCardFailed", ""));
                                ItemStop_Click(null, null);
                                return;
                            }
                        }
                        msg = Pub.GetResText(formCode, "MsgCardFaInfoCard", "");
                        msg = string.Format(msg, EmpNo, EmpName, CardSectorNo);
                    }
                    else
                    {
                        //CardSectorNo = "";
                        msg = Pub.GetResText(formCode, "MsgCardFaInfo", "");
                        msg = string.Format(msg, EmpNo, EmpName);
                    }
                    RefreshMsg(msg);
LoopCard:
                    Application.DoEvents();
                    if (!IsFaCard)
                    {
                        ItemStop_Click(null, null);
                        return;
                    }
                    CardData10 = "";
                    CardDataH  = "";
                    CardData8  = "";
                    if (!Pub.CheckCardExists(ref CardData10, ref CardDataH, ref CardData8, ref ErrMsg))
                    {
                        lblResult.Text = ErrMsg;
                        goto LoopCard;
                    }
                    cardRet = db.CheckCardPhysicsNo(EmpSysID, CardData10, ref UseEmpNo);
                    if (cardRet == 1)
                    {
                        lblResult.Text = string.Format(Pub.GetResText(formCode, "MsgCardCheckExistsUseing", ""),
                                                       CardData10, UseEmpNo);
                        goto LoopCard;
                    }
                    else if (cardRet == 2)
                    {
                        lblResult.Text = string.Format(Pub.GetResText(formCode, "MsgCardExistsBlackAgainA", ""), CardData10);
                        goto LoopCard;
                    }
                    else if (cardRet == 3)
                    {
                        goto LoopCard;
                    }
                    pubData = new HSUNFK.TCardPubData();
                    cardRet = DeviceObject.objCPIC.ReadCardInfoPub(SystemInfo.IsLongEmpID, ref pubData);
                    if (cardRet != 0)
                    {
                        lblResult.Text = Pub.GetCardMsg(cardRet);
                        goto LoopCard;
                    }
                    if (pubData.DealersCode != SystemInfo.DealersCode)
                    {
                        lblResult.Text = Pub.GetResText(formCode, "ErrorIllegalCard", "");
                        goto LoopCard;
                    }
                    if ((pubData.CardNo != "") && (Convert.ToUInt32(pubData.CardNo) > 0))
                    {
                        lblResult.Text = Pub.GetResText(formCode, "MsgCardFaExists", "");
                        goto LoopCard;
                    }
                    lblResult.Text = Pub.GetResText(formCode, "MsgCardFaing", "");
                    if (CardSectorNo == "")
                    {
                        CardSectorNo = db.GetMaxCardSectorNo();
                    }
                    //CardSectorNo = CardData10;
                    Application.DoEvents();
                    IsValidCard = true;
LoopCardExists:
                    pubData.EmpNo         = EmpNo;
                    pubData.EmpName       = EmpName;
                    pubData.CardNo        = CardSectorNo;
                    pubData.CardTypeID    = CardTypeID;
                    pubData.CardPWD       = CardPWD;
                    pubData.DealersCode   = SystemInfo.DealersCode;
                    pubData.CustomersCode = SystemInfo.CustomersCode;
                    pubData.CardBeginDate = CardStartDate;
                    pubData.CardEndDate   = CardEndDate;
                    pubData.IsCheckOrder  = Convert.ToByte(CardCheckOrder);
                    if (!db.GetServerDate(ref d))
                    {
                        ItemStop_Click(null, null);
                        return;
                    }
                    sfData         = new HSUNFK.TCardSFData();
                    sfData.Balance = DiscountM;
                    sfData.UseDate = d;
                    if (sfData.Balance > 0)
                    {
                        sfData.UseTimes = UseTimes + 1;
                    }
                    else
                    {
                        sfData.UseTimes = UseTimes;
                    }
                    if (DiscountM != CardStored)
                    {
                        sfData.UseTimes = sfData.UseTimes + 1;
                    }
                    sfData.BtMonery = 0;
                    sfData.BtDate   = "000000";
                    skData          = new HSUNFK.TCardSKData();
                    skData.CardID   = pubData.CardNo;
                    skData.CardTime = d;
                    IsError         = false;
ContinuePS:
                    Application.DoEvents();
                    if (IsError)
                    {
                        CardNo10 = "";
                        CardNoH  = "";
                        CardNo8  = "";
                        if (!Pub.CheckCardExists(ref CardNo10, ref CardNoH, ref CardNo8, false))
                        {
                            lblResult.Text = Pub.GetResText(formCode, "ReadCardError3", "");
                            goto ContinuePS;
                        }
                        if (CardNo10 != CardData10)
                        {
                            if (Pub.MessageBoxShowQuestion(Pub.GetResText(formCode, "MsgCardSame", "")))
                            {
                                if (IsValidCard)
                                {
                                    db.EmpCardFa(this.Text, Oprt, EmpSysID, CardSectorNo, CardData10, CardData8, CardStored,
                                                 sfData.UseDate, sfData.UseTimes, CardStored, DiscountM, 70, 80, CardData10, MacTAG, ref reStatus);
                                    if (reStatus == 0)
                                    {
                                        Pub.ClearCardInfo();
                                        goto AgainCard;
                                    }
                                    else
                                    {
                                        db.EmpHistoryCard(this.Text, Oprt, EmpSysID, CardSectorNo, Fad, 1);
                                    }
                                }
                                IsFaOk = true;
                                ItemStop_Click(null, null);
                                return;
                            }
                            else
                            {
                                goto ContinuePS;
                            }
                        }
                        else
                        {
                            if (SystemInfo.AllowCustomerCardNo)
                            {
                                if (db.CardSectorNoIsExists(EmpSysID, CardSectorNo, ref CardNoDays))
                                {
                                    IsValidCard = false;
                                    if (CardNoDays == " ")
                                    {
                                        msg = Pub.GetResText(formCode, "MsgCardExistsBlackAgain", "");
                                    }
                                    else if (DateTime.TryParse(CardNoDays, out d))
                                    {
                                        msg = Pub.GetResText(formCode, "MsgCardExistsUseDaysAgain", "");
                                    }
                                    else
                                    {
                                        msg = Pub.GetResText(formCode, "MsgCardExistsUseingAgain", "");
                                    }
                                    msg = string.Format(msg, CardSectorNo, CardNoDays);
                                    Pub.ClearCardInfo();
                                    Pub.ShowErrorMsg(msg);
                                    CardSectorNo = db.GetMaxCardSectorNo(EmpSysID);
                                    if (CardSectorNo == "")
                                    {
                                        Pub.ShowErrorMsg(Pub.GetResText(formCode, "ErrorBuildCardFailed", ""));
                                        ItemStop_Click(null, null);
                                        return;
                                    }
                                    msg = Pub.GetResText(formCode, "MsgCardFaInfoCard", "");
                                    msg = string.Format(msg, EmpNo, EmpName, CardSectorNo);
                                    RefreshMsg(msg);
                                    goto LoopCardExists;
                                }
                            }
                            else
                            {
                                if (db.CardSectorNoIsExists(EmpSysID, CardSectorNo, ref CardNoDays))
                                {
                                    IsValidCard = false;
                                    if (CardNoDays == " ")
                                    {
                                        msg = Pub.GetResText(formCode, "MsgCardExistsBlackAgainA", "");
                                    }
                                    else if (DateTime.TryParse(CardNoDays, out d))
                                    {
                                        msg = Pub.GetResText(formCode, "MsgCardExistsUseDaysAgainA", "");
                                    }
                                    else
                                    {
                                        msg = Pub.GetResText(formCode, "MsgCardExistsUseingAgainA", "");
                                    }
                                    msg = string.Format(msg, CardSectorNo, CardNoDays);
                                    Pub.ClearCardInfo();
                                    Pub.ShowErrorMsg(msg);
                                    msg = Pub.GetResText(formCode, "MsgCardFaInfoCard", "");
                                    msg = string.Format(msg, EmpNo, EmpName, CardSectorNo);
                                    RefreshMsg(msg);
                                    goto LoopCardExists;
                                }
                            }
                        }
                        IsError     = false;
                        IsValidCard = true;
                    }
                    cardRet = Pub.WriteCardInfo(pubData, sfData, skData);
                    if (cardRet != 0)
                    {
                        if (Pub.MessageBoxShowQuestion(Pub.GetCardMsg(cardRet) + Pub.GetResText(formCode, "MsgContinue", "")))
                        {
                            if (IsValidCard)
                            {
                                db.EmpCardFa(this.Text, Oprt, EmpSysID, CardSectorNo, CardData10, CardData8, CardStored,
                                             sfData.UseDate, sfData.UseTimes, CardStored, DiscountM, 70, 80, CardData10, MacTAG, ref reStatus);
                                if (reStatus == 0)
                                {
                                    Pub.ClearCardInfo();
                                    goto AgainCard;
                                }
                                else
                                {
                                    db.EmpHistoryCard(this.Text, Oprt, EmpSysID, CardSectorNo, Fad, 1);
                                }
                            }
                            IsFaOk = true;
                            Pub.ClearCardInfo();
                            ItemStop_Click(null, null);
                            return;
                        }
                        else
                        {
                            IsError = true;
                            goto ContinuePS;
                        }
                    }
                    IsValidCard = true;
ContinueData:
                    Application.DoEvents();
                    if (!db.EmpCardFa(this.Text, Oprt, EmpSysID, CardSectorNo, CardData10, CardData8, CardStored,
                                      sfData.UseDate, sfData.UseTimes, CardStored, DiscountM, 20, 10, CardData10, MacTAG, ref reStatus))
                    {
                        if (Pub.MessageBoxShowQuestion(Pub.GetResText(formCode, "ErrorCardDB", "")))
                        {
                            Pub.ClearCardInfo();
                            Pub.ShowErrorMsg(Pub.GetResText(formCode, "MsgCardFaFailed", ""));
                            ItemStop_Click(null, null);
                            return;
                        }
                        else
                        {
                            goto ContinueData;
                        }
                    }
                    if (reStatus == 0)
                    {
                        Pub.ClearCardInfo();
                        goto AgainCard;
                    }
                    db.EmpHistoryCard(this.Text, Oprt, EmpSysID, CardSectorNo, Fad, 1);
                    lblResult.Text = Pub.GetResText(formCode, "MsgCardFaSuccess", "");
                    IsFaOk         = true;
                    Pub.CardBuzzer();
                    dr["CardSectorNo"]   = CardSectorNo;
                    dr["CardStatusName"] = CardStatusNormal;
                    db.UpdateEmpRegisterData(EmpSysID, 11, CardData10);
LoopNoCard:
                    Application.DoEvents();
                    if (!IsBatch || !IsFaCard || (i + 1 == dt.Rows.Count))
                    {
                        break;
                    }
                    if (DeviceObject.objCPIC.CardIsExists())
                    {
                        goto LoopNoCard;
                    }
                }
                IsFaCard = false;
                Application.DoEvents();
            }
            ItemStop_Click(null, null);
            lblResult.Text = "";
            lblMsg.Text    = Pub.GetResText(formCode, "MsgOprtComplete", "");
        }
コード例 #4
0
        private void btnOk_Click(object sender, EventArgs e)
        {
            if (dtpEnd.Value < dtpStart.Value)
            {
                Pub.MessageBoxShow(Pub.GetResText(formCode, "Error001", ""));
                return;
            }
            if (cbbRule.SelectedIndex < 0)
            {
                ShowErrorSelectCorrect(label3.Text);
                return;
            }
            bool selectDepart = false;

            for (int i = 0; i < tvDepart.Nodes.Count; i++)
            {
                if (tvDepart.Nodes[i].Checked)
                {
                    selectDepart = true;
                    break;
                }
                if (IsSelectDepart(tvDepart.Nodes[i]))
                {
                    selectDepart = true;
                    break;
                }
            }
            if (!selectDepart)
            {
                Pub.MessageBoxShow(Pub.GetResText(formCode, "ErrorSelectDepart", ""));
                return;
            }
            List <string> depart = new List <string>();

            for (int i = 0; i < tvDepart.Nodes.Count; i++)
            {
                if (tvDepart.Nodes[i].Checked)
                {
                    depart.Add(tvDepart.Nodes[i].Tag.ToString());
                }
                SelectDepartList(tvDepart.Nodes[i], ref depart);
            }
            string        ShiftRuleID = ((TIDAndName)cbbRule.Items[cbbRule.SelectedIndex]).id;
            List <string> sql         = new List <string>();
            string        DepartID    = "";
            DataTable     dt          = null;
            bool          IsError     = false;
            int           days        = (int)Pub.DateDiff(DateInterval.Day, dtpStart.Value, dtpEnd.Value);
            int           flag        = 0;
            int           CycDays     = 0;
            int           row         = 0;

            try
            {
                dt      = SystemInfo.db.GetDataTable(Pub.GetSQL(DBCode.DB_000205, new string[] { "3", ShiftRuleID }));
                flag    = Convert.ToInt32(dt.Rows[0]["ShiftRulecycID"].ToString());
                CycDays = Convert.ToInt32(dt.Rows[0]["ShiftRulecyc"].ToString());
                dt      = SystemInfo.db.GetDataTable(Pub.GetSQL(DBCode.DB_000205, new string[] { "4", ShiftRuleID }));
                for (int i = 0; i < depart.Count; i++)
                {
                    DepartID = depart[i];
                    sql.Add(Pub.GetSQL(DBCode.DB_000207, new string[] { "3", DepartID,
                                                                        dtpStart.Value.ToString(SystemInfo.SQLDateFMT), dtpEnd.Value.ToString(SystemInfo.SQLDateFMT) }));
                    switch (flag)
                    {
                    case 0:
                        row = 1;
                        for (int j = 0; j <= days; j++)
                        {
                            if (row > CycDays)
                            {
                                row = 1;
                            }
                            sql.Add(Pub.GetSQL(DBCode.DB_000207, new string[] { "2", DepartID,
                                                                                dtpStart.Value.AddDays(j).ToString(SystemInfo.SQLDateFMT), dt.Rows[row - 1]["ShiftID"].ToString() }));
                            row += 1;
                        }
                        break;

                    case 1:
                        for (int j = 0; j <= days; j++)
                        {
                            row = (int)dtpStart.Value.AddDays(j).DayOfWeek;
                            sql.Add(Pub.GetSQL(DBCode.DB_000207, new string[] { "2", DepartID,
                                                                                dtpStart.Value.AddDays(j).ToString(SystemInfo.SQLDateFMT), dt.Rows[row]["ShiftID"].ToString() }));
                        }
                        break;

                    case 2:
                        for (int j = 0; j <= days; j++)
                        {
                            row = dtpStart.Value.AddDays(j).Day;
                            sql.Add(Pub.GetSQL(DBCode.DB_000207, new string[] { "2", DepartID,
                                                                                dtpStart.Value.AddDays(j).ToString(SystemInfo.SQLDateFMT), dt.Rows[row - 1]["ShiftID"].ToString() }));
                        }
                        break;
                    }
                }
            }
            catch (Exception E)
            {
                IsError = true;
                Pub.ShowErrorMsg(E);
            }
            finally
            {
                if (dt != null)
                {
                    dt.Clear();
                    dt.Reset();
                }
            }
            if (IsError)
            {
                return;
            }
            if (SystemInfo.db.ExecSQL(sql) != 0)
            {
                return;
            }
            SystemInfo.db.WriteSYLog(this.Text, CurrentOprt, sql);
            //Pub.MessageBoxShow(Pub.GetResText(formCode, "MsgSaveSucceed", ""), MessageBoxIcon.Information);
            this.DialogResult = DialogResult.OK;
            this.Close();
        }
コード例 #5
0
        private void btnOk_Click(object sender, EventArgs e)
        {
            if (!CheckEmp())
            {
                return;
            }
            if (dtpStart.Value > dtpEnd.Value)
            {
                dtpStart.Focus();
                Pub.ShowErrorMsg(Pub.GetResText(formCode, "ErrorStartTimeBegreater", ""));
                return;
            }
            if (cbbType.SelectedIndex == -1)
            {
                cbbType.Focus();
                ShowErrorSelectCorrect(label7.Text);
                return;
            }
            string BillNo    = txtNo.Text;
            string EmpSysID  = txtEmpNo.Tag.ToString();
            string TypeSysID = ((TCommonType)cbbType.Items[cbbType.SelectedIndex]).sysID;
            string Reason    = txtReason.Text.Trim();

            if (!Pub.CheckTextMaxLength(label8.Text, Reason, txtReason.MaxLength))
            {
                return;
            }
            List <string>   sql      = new List <string>();
            int             days     = (int)Pub.DateDiff(DateInterval.Day, dtpStart.Value.Date, dtpEnd.Value.Date);
            DataTableReader dr       = null;
            bool            IsError  = false;
            bool            IsExists = true;

            try
            {
                if (SysID == "")
                {
                    while (IsExists)
                    {
                        dr = db.GetDataReader(Pub.GetSQL(DBCode.DB_002009, new string[] { "6", BillNo }));
                        if (!dr.Read())
                        {
                            IsExists = false;
                        }
                        dr.Close();
                        if (IsExists)
                        {
                            BillNo = GetBillNo();
                        }
                    }
                    GetSql(days, EmpSysID, BillNo, TypeSysID, Reason, ref sql);
                    if (cardGrid.DataSource != null)
                    {
                        DataTable dtGrid = (DataTable)cardGrid.DataSource;
                        for (int i = 0; i < dtGrid.Rows.Count; i++)
                        {
                            if (dtGrid.Rows[i]["EmpSysID"].ToString() == EmpSysID)
                            {
                                continue;
                            }
                            GetSql(days, dtGrid.Rows[i]["EmpSysID"].ToString(), BillNo, TypeSysID, Reason, ref sql);
                        }
                    }
                }
                else
                {
                    GetSql(days, EmpSysID, BillNo, TypeSysID, Reason, ref sql);
                }
            }
            catch (Exception E)
            {
                IsError = true;
                Pub.ShowErrorMsg(E);
            }
            finally
            {
                if (dr != null)
                {
                    dr.Close();
                }
                dr = null;
            }
            if (IsError)
            {
                return;
            }
            if (db.ExecSQL(sql) != 0)
            {
                return;
            }
            db.WriteSYLog(this.Text, CurrentOprt, sql);
            Pub.MessageBoxShow(Pub.GetResText(formCode, "MsgSaveSucceed", ""), MessageBoxIcon.Information);
            this.DialogResult = DialogResult.OK;
            this.Close();
        }
コード例 #6
0
        private void btnOk_Click(object sender, EventArgs e)
        {
            if (!CheckEmp())
            {
                return;
            }
            if (dtpStart.Value > dtpEnd.Value)
            {
                dtpStart.Focus();
                Pub.ShowErrorMsg(Pub.GetResText(formCode, "ErrorStartTimeBegreater", ""));
                return;
            }
            string BillNo   = txtNo.Text;
            string EmpSysID = txtEmpNo.Tag.ToString();
            string Reason   = txtReason.Text.Trim();

            if (!Pub.CheckTextMaxLength(label8.Text, Reason, txtReason.MaxLength))
            {
                return;
            }
            string[]        TypeSysID = new string[3];
            int[]           StartTime = new int[3];
            int[]           EndTime   = new int[3];
            int[]           OtBefore  = new int[3];
            int[]           OtAfter   = new int[3];
            List <string>   sql       = new List <string>();
            int             days      = (int)Pub.DateDiff(DateInterval.Day, dtpStart.Value.Date, dtpEnd.Value.Date);
            DataTableReader dr        = null;
            bool            IsError   = false;
            bool            IsExists  = true;
            TextBox         txt;
            MaskedTextBox   txtA;
            MaskedTextBox   txtB;
            ComboBox        cbb;
            const int       DaySeconds = 24 * 3600;
            DateTime        dt         = new DateTime();

            for (int i = 1; i <= 3; i++)
            {
                txtA = (MaskedTextBox)groupBox2.Controls["txtStartTime" + i.ToString()];
                txtB = (MaskedTextBox)groupBox2.Controls["txtEndTime" + i.ToString()];
                if ((txtA.Text == "00:00") && (txtB.Text == "00:00"))
                {
                    continue;
                }
                if (!DateTime.TryParse(txtA.Text, out dt))
                {
                    txtA.Focus();
                    Pub.ShowErrorMsg(Pub.GetResText(formCode, "Error001", ""));
                    return;
                }
                StartTime[i - 1] = dt.Hour * 3600 + dt.Minute * 60;
                cbb = (ComboBox)groupBox2.Controls["cbbInNextDay" + i.ToString()];
                if (cbb.SelectedIndex == 1)
                {
                    StartTime[i - 1] += DaySeconds;
                }
                if (!DateTime.TryParse(txtB.Text, out dt))
                {
                    txtB.Focus();
                    Pub.ShowErrorMsg(Pub.GetResText(formCode, "Error002", ""));
                    return;
                }
                EndTime[i - 1] = dt.Hour * 3600 + dt.Minute * 60;
                cbb            = (ComboBox)groupBox2.Controls["cbbOutNextDay" + i.ToString()];
                if (cbb.SelectedIndex == 1)
                {
                    EndTime[i - 1] += DaySeconds;
                }
                if (StartTime[i - 1] >= EndTime[i - 1])
                {
                    txtB.Focus();
                    Pub.ShowErrorMsg(Pub.GetResText(formCode, "Error003", ""));
                    return;
                }
                cbb = (ComboBox)groupBox2.Controls["cbbOtType" + i.ToString()];
                if (cbb.SelectedIndex < 1)
                {
                    cbb.Focus();
                    ShowErrorSelectCorrect(label13.Text);
                    return;
                }
                TypeSysID[i - 1] = ((TCommonType)cbb.Items[cbb.SelectedIndex]).sysID;
                txt = (TextBox)groupBox2.Controls["txtBefore" + i.ToString()];
                int.TryParse(txt.Text.Trim(), out OtBefore[i - 1]);
                OtBefore[i - 1] *= 60;
                txt              = (TextBox)groupBox2.Controls["txtAfter" + i.ToString()];
                int.TryParse(txt.Text.Trim(), out OtAfter[i - 1]);
                OtAfter[i - 1] *= 60;
            }
            try
            {
                if (SysID == "")
                {
                    while (IsExists)
                    {
                        dr = db.GetDataReader(Pub.GetSQL(DBCode.DB_002010, new string[] { "6", BillNo }));
                        if (!dr.Read())
                        {
                            IsExists = false;
                        }
                        dr.Close();
                        if (IsExists)
                        {
                            BillNo = GetBillNo();
                        }
                    }
                    GetSql(days, EmpSysID, BillNo, TypeSysID, StartTime, EndTime, OtBefore, OtAfter, Reason, ref sql);
                    if (cardGrid.DataSource != null)
                    {
                        DataTable dtGrid = (DataTable)cardGrid.DataSource;
                        for (int i = 0; i < dtGrid.Rows.Count; i++)
                        {
                            if (dtGrid.Rows[i]["EmpSysID"].ToString() == EmpSysID)
                            {
                                continue;
                            }
                            GetSql(days, dtGrid.Rows[i]["EmpSysID"].ToString(), BillNo, TypeSysID, StartTime, EndTime, OtBefore,
                                   OtAfter, Reason, ref sql);
                        }
                    }
                }
                else
                {
                    GetSql(days, EmpSysID, BillNo, TypeSysID, StartTime, EndTime, OtBefore, OtAfter, Reason, ref sql);
                }
            }
            catch (Exception E)
            {
                IsError = true;
                Pub.ShowErrorMsg(E);
            }
            finally
            {
                if (dr != null)
                {
                    dr.Close();
                }
                dr = null;
            }
            if (IsError)
            {
                return;
            }
            if (db.ExecSQL(sql) != 0)
            {
                return;
            }
            db.WriteSYLog(this.Text, CurrentOprt, sql);
            Pub.MessageBoxShow(Pub.GetResText(formCode, "MsgSaveSucceed", ""), MessageBoxIcon.Information);
            this.DialogResult = DialogResult.OK;
            this.Close();
        }
コード例 #7
0
        private void btnRefresh_Click(object sender, EventArgs e)
        {
            StartDate = dtpStart.Value;
            long days = Pub.DateDiff(DateInterval.Day, StartDate, dtpEnd.Value) + 1;

            dataGrid.Rows.Clear();
            dataGrid.Columns.Clear();
            if (days <= 0)
            {
                return;
            }
            dataGrid.Columns.Add("EmpNo", Pub.GetResText(formCode, "EmpNo", ""));
            dataGrid.Columns.Add("EmpName", Pub.GetResText(formCode, "EmpName", ""));
            dataGrid.Columns.Add("MealType", Pub.GetResText(formCode, "lblMealType", ""));
            for (int i = 0; i < days; i++)
            {
                AddColumn(dataGrid, 1, "DAY" + i.ToString(), false, false, 1, 30);
                dataGrid.Columns[dataGrid.ColumnCount - 1].HeaderText = dtpStart.Value.AddDays(i).Day.ToString();
            }
            AddColumn(dataGrid, 1, "SelectCheck", false, false, 1, 50);
            dataGrid.Columns[dataGrid.ColumnCount - 1].HeaderText = Pub.GetResText(formCode, "SelectCheck", "");
            if (dtEmp.Rows.Count > 0)
            {
                dataGrid.Rows.Add(dtEmp.Rows.Count * 4);
            }
            for (int i = 0; i < dataGrid.ColumnCount; i++)
            {
                dataGrid.Columns[i].SortMode = DataGridViewColumnSortMode.NotSortable;
                dataGrid.Columns[i].ReadOnly = true;
                if (i <= 1)
                {
                    dataGrid.Columns[i].Width = 70;
                }
                else if ((i == 2) || (i == dataGrid.ColumnCount - 1))
                {
                    dataGrid.Columns[i].Width = 50;
                }
                else
                {
                    dataGrid.Columns[i].Width    = 30;
                    dataGrid.Columns[i].ReadOnly = false;
                }
            }
            AddColumn(dataGrid, 0, "EmpSysID", true, false, 0, 0);
            AddColumn(dataGrid, 0, "CardSectorNo", true, false, 0, 0);
            AddColumn(dataGrid, 0, "MealTypeID", true, false, 0, 0);
            dataGrid.MergeColumnNames.Add("EmpNo");
            dataGrid.MergeColumnNames.Add("EmpName");
            for (int i = 0; i < dtEmp.Rows.Count; i++)
            {
                for (int j = 0; j < 4; j++)
                {
                    dataGrid[dataGrid.ColumnCount - 3, i * 4 + j].Value = dtEmp.Rows[i]["EmpSysID"].ToString();
                    dataGrid[dataGrid.ColumnCount - 2, i * 4 + j].Value = dtEmp.Rows[i]["CardSectorNo"].ToString();
                    dataGrid[dataGrid.ColumnCount - 1, i * 4 + j].Value = j + 1;
                    dataGrid[0, i * 4 + j].Value = dtEmp.Rows[i]["EmpNo"].ToString();
                    dataGrid[1, i * 4 + j].Value = dtEmp.Rows[i]["EmpName"].ToString();
                    if (mealList.Count == 0)
                    {
                        switch (j)
                        {
                        case 0:
                            dataGrid[2, i * 4 + j].Value = button1.Text;
                            break;

                        case 1:
                            dataGrid[2, i * 4 + j].Value = button2.Text;
                            break;

                        case 2:
                            dataGrid[2, i * 4 + j].Value = button3.Text;
                            break;

                        case 3:
                            dataGrid[2, i * 4 + j].Value = button4.Text;
                            break;
                        }
                    }
                    else
                    {
                        dataGrid[2, i * 4 + j].Value = mealList[j].name;
                    }
                }
            }
        }
コード例 #8
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (dtpStart.Value > dtpEnd.Value)
            {
                dtpStart.Focus();
                Pub.MessageBoxShow(Pub.GetResText(formCode, "ErrorStartDateBegreater", ""));
                return;
            }
            int  week = 0;
            long days = Pub.DateDiff(DateInterval.Day, dtpStart.Value.Date, dtpEnd.Value.Date) + 1;

            if (days > 31)
            {
                Pub.MessageBoxShow(string.Format(Pub.GetResText(formCode, "Error001", ""), 31));
                return;
            }
            if (cbWeek.Checked)
            {
                week = 1;
                if (days > 7)
                {
                    Pub.MessageBoxShow(string.Format(Pub.GetResText(formCode, "Error001", ""), 7));
                    return;
                }
            }
            if (rbEmp.Checked && (cardGrid.RowCount == 0))
            {
                Pub.MessageBoxShow(Pub.GetResText(formCode, "ErrorSelectEmp", ""));
                return;
            }
            IsWorking = true;
            RefreshControl();
            string    msg       = Pub.GetResText(formCode, "Msg001", "");
            bool      IsError   = false;
            DateTime  StartTime = DateTime.Now;
            DataTable dt        = null;

            label3.Text   = msg;
            progBar.Value = 0;
            string   EmpNo;
            DateTime StartDate = dtpStart.Value.Date;
            DateTime EndDate   = dtpEnd.Value.Date;
            int      empCount  = 0;

            try
            {
                if (SystemInfo.DBType == 0)
                {
                    SystemInfo.objACKQ.PKQ_Temp_KQ_KQData(StartDate, EndDate);
                }

                SystemInfo.db.WriteConfig("KQ", "AllowAdjust", true);
                if (rbAll.Checked)
                {
                    dt = SystemInfo.db.GetDataTable(Pub.GetSQL(DBCode.DB_000213, new string[] { "0" }));
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        label3.Text = msg + string.Format("{0}/{1}", i + 1, dt.Rows.Count) + "  [" +
                                      dt.Rows[i]["DepartID"].ToString() + "]" + dt.Rows[i]["DepartName"].ToString() + " - [" +
                                      dt.Rows[i]["EmpNo"].ToString() + "]" + dt.Rows[i]["EmpName"].ToString() + "  " +
                                      Pub.GetDateDiffTimes(StartTime, DateTime.Now, true);
                        EmpNo = dt.Rows[i]["EmpNo"].ToString();
                        if (!CalcEmpData(EmpNo, StartDate, EndDate, week))
                        {
                            IsError = true;
                            break;
                        }
                        empCount     += 1;
                        progBar.Value = (i + 1) * 100 / dt.Rows.Count;
                        if (!IsWorking)
                        {
                            break;
                        }
                        Application.DoEvents();
                    }
                }
                else
                {
                    DataTable dtGrid = (DataTable)cardGrid.DataSource;
                    for (int i = 0; i < dtGrid.Rows.Count; i++)
                    {
                        label3.Text = msg + string.Format("{0}/{1}", i + 1, cardGrid.RowCount) + "  [" +
                                      dtGrid.Rows[i]["DepartID"].ToString() + "]" + dtGrid.Rows[i]["DepartName"].ToString() + " - [" +
                                      dtGrid.Rows[i]["EmpNo"].ToString() + "]" + dtGrid.Rows[i]["EmpName"].ToString() + "  " +
                                      Pub.GetDateDiffTimes(StartTime, DateTime.Now, true);
                        EmpNo = dtGrid.Rows[i]["EmpNo"].ToString();
                        if (!CalcEmpData(EmpNo, StartDate, EndDate, week))
                        {
                            IsError = true;
                            break;
                        }
                        empCount     += 1;
                        progBar.Value = (i + 1) * 100 / cardGrid.RowCount;
                        if (!IsWorking)
                        {
                            break;
                        }
                        Application.DoEvents();
                    }
                }
                SystemInfo.db.DeleteConfig("KQ", "AllowAdjust");
            }
            catch (Exception E)
            {
                IsError = true;
                Pub.ShowErrorMsg(E);
            }
            finally
            {
                if (dt != null)
                {
                    dt.Clear();
                    dt.Reset();
                }
                dt = null;
            }
            IsWorking = false;
            RefreshControl();
            if (IsError)
            {
                msg = Pub.GetResText(formCode, "Msg003", "");
            }
            else
            {
                msg = Pub.GetResText(formCode, "Msg002", "");
            }
            label3.Text = string.Format(msg, empCount, Pub.GetDateDiffTimes(StartTime, DateTime.Now, true));
        }