Esempio n. 1
0
        public Boolean insertEmailData(emaildata edata)
        {
            Boolean status   = true;
            string  utString = "";

            try
            {
                string dtString = UpdateTable.getSQLDateTime().ToString("dd-MM-yyyy HH:mm:ss");
                edata.EmailData = edata.EmailData + ".\nTime:" + dtString;
                string updateSQL = "insert into EmailData (EmailData,ToAddress,Subject,Status,CreateTime,CreateUser)" +
                                   "values (" +
                                   "'" + edata.EmailData + "'," +
                                   "'" + edata.ToAddress + "'," +
                                   "'" + edata.Subject + "'," +
                                   edata.status + "," +
                                   "GETDATE()" + "," +
                                   "'" + Login.userLoggedIn + "'" + ")";
                utString = utString + updateSQL + Main.QueryDelimiter;
                utString = utString +
                           ActivityLogDB.PrepareActivityLogQquerString("insert", "EmailData", "", updateSQL) +
                           Main.QueryDelimiter;
                if (!UpdateTable.UT(utString))
                {
                    status = false;
                }
            }
            catch (Exception)
            {
                MessageBox.Show(this.ToString() + "-" + System.Reflection.MethodBase.GetCurrentMethod().Name + "() : Error");
                status = false;
            }
            return(status);
        }
Esempio n. 2
0
        //create comment string using comment gridview and edited string of the user
        public string processNewComment(DataGridView dgv, string cmntStr, string uid, string eName, int Status)
        {
            try
            {
                int cnt = dgv.Rows.Count;
                int row = getLastCommentRow(dgv, uid);
                if (row >= 0)
                {
                    dgv.Rows[row].Cells["Date"].Value      = UpdateTable.getSQLDateTime().ToString("yyyy-MM-dd");
                    dgv.Rows[row].Cells["Commenter"].Value = eName;
                    dgv.Rows[row].Cells["Comment"].Value   = cmntStr;
                    dgv.Rows[row].Cells["Status"].Value    = Status;
                    dgv.Rows[row].Cells["UserId"].Value    = uid;
                }
                else
                {
                    dgv.Rows.Add();
                    dgv.Rows[dgv.Rows.Count - 1].Cells["SlNo"].Value      = 1;
                    dgv.Rows[dgv.Rows.Count - 1].Cells["Date"].Value      = UpdateTable.getSQLDateTime().ToString("yyyy-MM-dd");
                    dgv.Rows[dgv.Rows.Count - 1].Cells["Commenter"].Value = eName;
                    dgv.Rows[dgv.Rows.Count - 1].Cells["Comment"].Value   = cmntStr;
                    dgv.Rows[dgv.Rows.Count - 1].Cells["Status"].Value    = Status;
                    dgv.Rows[dgv.Rows.Count - 1].Cells["UserID"].Value    = uid;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(this.ToString() + "-" + System.Reflection.MethodBase.GetCurrentMethod().Name + "() : Error");
            }
            string finalStr = DGVtoString(dgv);

            ////MessageBox.Show("DETAILS:\n" + finalStr);
            return(finalStr);
        }
Esempio n. 3
0
        public Boolean validateMovementReg(movementregister mr)
        {
            Boolean status = true;

            try
            {
                if (mr.EmployeeID.Trim().Length == 0 || mr.EmployeeID == null)
                {
                    return(false);
                }

                if (mr.ExitTimePlanned == null)
                {
                    return(false);
                }
                if (mr.ReturnTimePlanned == null)
                {
                    return(false);
                }
                //DateTime a = UpdateTable.getSQLDateTime();
                //DateTime dt = mr.ExitTimePlanned;
                //int secs = (mr.ExitTimePlanned - UpdateTable.getSQLDateTime()).Seconds;
                //double sec = mr.ExitTimePlanned.Subtract(UpdateTable.getSQLDateTime()).TotalSeconds;
                DateTime tdt  = UpdateTable.getSQLDateTime();
                Double   val1 = mr.ExitTimePlanned.Subtract(tdt).TotalSeconds;
                Double   val2 = mr.ReturnTimePlanned.Subtract(mr.ExitTimePlanned).TotalSeconds;
                if ((val1 < -300) || (val2 < 600))
                {
                    return(false);
                }
                if (mr.Purpose.Trim().Length == 0 || mr.Purpose == null)
                {
                    return(false);
                }
                if (mr.ModeOfTravel.Trim().Length == 0 || mr.ModeOfTravel == null)
                {
                    return(false);
                }
                if (mr.ApproveUser.Trim().Length == 0 || mr.ApproveUser == null)
                {
                    return(false);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Validation Failed.");
                return(false);
            }

            return(status);
        }
Esempio n. 4
0
        //public Boolean validateOfficeWDforHW(officehw ofhw)
        //{
        //    int count = 0;
        //    Boolean status = false;
        //    try
        //    {
        //        string query = "select Description from OfficeHW where  Date='" + ofhw.date.ToString("yyyy-MM-dd") + "'";
        //        SqlConnection conn = new SqlConnection(Login.connString);
        //        SqlCommand cmd = new SqlCommand(query, conn);
        //        conn.Open();
        //        SqlDataReader reader = cmd.ExecuteReader();
        //        if (reader.Read())
        //        {
        //            status = true;
        //        }
        //        conn.Close();
        //    }
        //    catch (Exception ex)
        //    {
        //        status = false;
        //    }
        //    return status;
        //}

        public List <string> validateOfficeWDforWO(HolidayList ofhw)
        {
            string        offc    = "";
            List <string> offlist = new List <string>();

            try
            {
                string[] office = ofhw.officeID.Split(Main.delimiter1);
                foreach (string ofce in office)
                {
                    if (ofce != "")
                    {
                        string        query = "select Weekoffs from OfficeWeekOff where  OfficeID='" + ofce + "'";
                        SqlConnection conn  = new SqlConnection(Login.connString);
                        SqlCommand    cmd   = new SqlCommand(query, conn);
                        conn.Open();
                        SqlDataReader reader = cmd.ExecuteReader();
                        if (reader.Read())
                        {
                            List <DateTime> allweekenddate = GetAllweekends(UpdateTable.getSQLDateTime().Year, reader.GetString(0));
                            if (!allweekenddate.Contains(ofhw.date.Date))
                            {
                                offc = ofce;
                            }
                        }
                        else
                        {
                            offc = ofce;
                        }
                        conn.Close();
                        if (offc != "")
                        {
                            offlist.Add(offc);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("validateOfficeWDforWO Error!!!");
            }
            return(offlist);
        }
Esempio n. 5
0
        public static Boolean IsAllowToRejectClosedComplaint(workplacecr wp) //within 2 days of rejection or completion
        {
            Boolean  stat      = true;
            int      n         = 0;
            DateTime closeTime = DateTime.MinValue;

            try
            {
                string        query = "";
                SqlConnection conn  = new SqlConnection(Login.connString);
                query = "select CloseTime" +
                        " from WorkplaceCR " +
                        " where EmployeeID='" + wp.EmployeeID + "' and ID = " + wp.rowID;

                SqlCommand cmd = new SqlCommand(query, conn);
                conn.Open();
                SqlDataReader reader = cmd.ExecuteReader();
                if (reader.Read())
                {
                    closeTime = reader.GetDateTime(0);
                    n         = 1;
                }
                conn.Close();
                if (n == 1)
                {
                    if ((UpdateTable.getSQLDateTime().Date - closeTime.Date).TotalDays > 2)
                    {
                        stat = false;
                    }
                    else
                    {
                        stat = true;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error querying Complaint Details For Accept Status");
            }
            return(stat);
        }
Esempio n. 6
0
        public List <HolidayList> getOfficeWD()
        {
            HolidayList        Wdlist;
            List <HolidayList> OfficeWDList = new List <HolidayList>();

            try
            {
                string        query = "select RowID,Type,Date,officeID,Description from OfficeWorkingDay  where datepart(yyyy,Date)='" + UpdateTable.getSQLDateTime().Year + "' ";
                SqlConnection conn  = new SqlConnection(Login.connString);
                SqlCommand    cmd   = new SqlCommand(query, conn);
                conn.Open();
                SqlDataReader reader = cmd.ExecuteReader();
                while (reader.Read())
                {
                    Wdlist             = new HolidayList();
                    Wdlist.RowID       = reader.GetInt32(0);
                    Wdlist.Type        = reader.GetString(1);
                    Wdlist.date        = reader.GetDateTime(2);
                    Wdlist.officeID    = reader.GetString(3);
                    Wdlist.Description = reader.GetString(4);
                    OfficeWDList.Add(Wdlist);
                }
                conn.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(System.Reflection.MethodBase.GetCurrentMethod().Name + "() : Error");
            }
            return(OfficeWDList);
        }
Esempio n. 7
0
        //---
        //---
        public Boolean updateGTNInStock(gtnheader gtnh, List <gtndetail> gtndList)
        {
            Boolean  status    = true;
            string   utString  = "";
            string   updateSQL = "";
            DateTime dt        = UpdateTable.getSQLDateTime();

            try
            {
                foreach (gtndetail gtnd in gtndList)
                {
                    List <stock> ItemStock = GetItemStock(gtnd.StockitemID, gtnh.FromLocation);
                    double       tqty      = 0;
                    //check quantity availability
                    foreach (stock stk in ItemStock)
                    {
                        //quantity check
                        tqty = tqty + stk.PresentStock;
                    }
                    if (tqty < gtnd.Quantity)
                    {
                        //not enough quantity for issue
                        status = false;
                        break;
                    }
                    //update stock in list
                    double gtnqty = 0;
                    double balqty = gtnd.Quantity;
                    foreach (stock stk in ItemStock)
                    {
                        if (balqty <= stk.PresentStock)
                        {
                            gtnqty           = balqty;
                            stk.PresentStock = stk.PresentStock - balqty;
                            balqty           = 0;
                        }
                        else
                        {
                            //stock not sufficient
                            gtnqty           = stk.PresentStock;
                            balqty           = balqty - stk.PresentStock;
                            stk.PresentStock = 0;
                        }
                        //Delete GTNdetail
                        updateSQL = "Delete from GTNDetail where DocumentID='" + gtnh.DocumentID + "'" +
                                    " and TemporaryNo=" + gtnh.TemporaryNo +
                                    " and TemporaryDate='" + gtnh.TemporaryDate.ToString("yyyy-MM-dd") + "'" +
                                    " and StockItemID='" + stk.StockItemID + "'";
                        utString = utString + updateSQL + Main.QueryDelimiter;
                        utString = utString +
                                   ActivityLogDB.PrepareActivityLogQquerString("delete", "GTNDetail", "", updateSQL) +
                                   Main.QueryDelimiter;
                        //create GTNDetail insert string
                        updateSQL = CreateGTNDetailString(stk, gtnh);
                        if (updateSQL.Trim().Length > 0)
                        {
                            utString = utString + updateSQL + Main.QueryDelimiter;
                            utString = utString +
                                       ActivityLogDB.PrepareActivityLogQquerString("insert", "GTNDetail", "", updateSQL) +
                                       Main.QueryDelimiter;
                        }
                        else
                        {
                            status = false;
                            break;
                        }
                        //create stock update string
                        updateSQL = "Update stock set PresentStock=" + stk.PresentStock + " where RowID=" + stk.RowID;
                        utString  = utString + updateSQL + Main.QueryDelimiter;
                        utString  = utString +
                                    ActivityLogDB.PrepareActivityLogQquerString("update", "Stock", "", updateSQL) +
                                    Main.QueryDelimiter;
                        //create stock insert string
                        updateSQL = createGTNStockInsertString(gtnqty, stk, gtnh, gtnh.ToLocation);
                        if (updateSQL.Trim().Length > 0)
                        {
                            utString = utString + updateSQL + Main.QueryDelimiter;
                            utString = utString +
                                       ActivityLogDB.PrepareActivityLogQquerString("insert", "Stock", "", updateSQL) +
                                       Main.QueryDelimiter;
                        }
                        else
                        {
                            status = false;
                            break;
                        }
                    }
                    if (!status)
                    {
                        break;
                    }
                }
                if (status)
                {
                    //update tables
                    if (!UpdateTable.UT(utString))
                    {
                        status = false;
                    }
                }
            }
            catch (Exception ex)
            {
                status = false;
            }
            return(status);
        }
Esempio n. 8
0
        public Boolean ApproveInvoiceInHeader(invoiceinheader inh)
        {
            Boolean status   = true;
            string  utString = "";

            try
            {
                string updateSQL = "update InvoiceInHeader set DocumentStatus=99, status=1 " +
                                   ", ApproveUser='******'" +
                                   ", commentStatus='" + inh.CommentStatus + "'" +
                                   ", DocumentNo=" + inh.DocumentNo +
                                   ", DocumentDate=convert(date, getdate())" +
                                   " where DocumentID='" + inh.DocumentID + "'" +
                                   " and TemporaryNo=" + inh.TemporaryNo +
                                   " and TemporaryDate='" + inh.TemporaryDate.ToString("yyyy-MM-dd") + "'";
                utString = utString + updateSQL + Main.QueryDelimiter;
                utString = utString +
                           ActivityLogDB.PrepareActivityLogQquerString("update", "InvoiceInHeader", "", updateSQL) +
                           Main.QueryDelimiter;

                string narration = "Puchase against Invoice No " + inh.DocumentNo + "," +
                                   "Dated " + UpdateTable.getSQLDateTime().ToString("dd-MM-yyyy") + "," +
                                   "Party:" + inh.CustomerName;

                int      PJVNo   = 0;                            //Journal No
                DateTime PJVDate = DateTime.Parse("1900-01-01"); //Journal Date
                //int SJVTempNo = 0; //Temporary No
                //DateTime SJVTempDate = DateTime.Parse("1900-01-01"); //Temporary Date

                if (inh.PJVNo == 0 && inh.PJVTNo > 0) // JV Available but not approved
                {
                    PJVNo   = DocumentNumberDB.getNewNumber("PJV", 2);
                    PJVDate = UpdateTable.getSQLDateTime();
                }
                else //JV Available and approved // JV Not available
                {
                    PJVNo   = inh.PJVNo;
                    PJVDate = inh.PJVDate;
                }

                updateSQL = "update PJVHeader set DocumentStatus=99, status=1 ,InvReferenceNo = " + inh.RowID +
                            ", ApproveUser='******'" +
                            ", JournalNo=" + PJVNo +
                            ", JournalDate= '" + PJVDate.ToString("yyyy-MM-dd") +
                            "', Narration='" + narration + "'" +
                            " where InvDocumentID='" + inh.DocumentID + "'" +
                            " and InvTempNo=" + inh.TemporaryNo +
                            " and InvTempDate='" + inh.TemporaryDate.ToString("yyyy-MM-dd") + "'";
                utString = utString + updateSQL + Main.QueryDelimiter;
                utString = utString +
                           ActivityLogDB.PrepareActivityLogQquerString("update", "PJVHeader", "", updateSQL) +
                           Main.QueryDelimiter;

                updateSQL = "update InvoiceInHeader set PJVNo='" + PJVNo + "'" +
                            ", PJVDate='" + PJVDate.ToString("yyyy-MM-dd") + "'" +
                            " where DocumentID='" + inh.DocumentID + "'" +
                            " and TemporaryNo=" + inh.TemporaryNo +
                            " and TemporaryDate='" + inh.TemporaryDate.ToString("yyyy-MM-dd") + "'";
                utString = utString + updateSQL + Main.QueryDelimiter;
                utString = utString +
                           ActivityLogDB.PrepareActivityLogQquerString("update", "InvoiceInHeader", "", updateSQL) +
                           Main.QueryDelimiter;

                if (!UpdateTable.UT(utString))
                {
                    status = false;
                }
            }
            catch (Exception)
            {
                status = false;
            }
            return(status);
        }