// POST api/ojournalvoucher
        public RTNMANVAL Post([FromBody] JV value)
        {
            RTNMANVAL returnVal = null;

            SAPbobsCOM.Company oCompany = null;
            string             newKey   = "";

            try
            {
                oCompany = Company.GetCompany(Properties.Settings.Default.StrDbServer, Properties.Settings.Default.StrDbUserName, Properties.Settings.Default.StrDbPassword,
                                              Properties.Settings.Default.StrDbName, Properties.Settings.Default.StrSapB1UserName, Properties.Settings.Default.StrSapB1Password,
                                              Properties.Settings.Default.StrSapB1LicenseServer);

                newKey = Logic.SAP.SAP_JV2.AddData(oCompany, value);

                returnVal = new RTNMANVAL()
                {
                    errorCode = "0",
                    message   = "Data has beed added",
                    value     = newKey
                };
            }
            catch (Exception e)
            {
                returnVal = new RTNMANVAL()
                {
                    errorCode = "-1",
                    message   = e.Message.ToString()
                };
            }
            return(returnVal);
        }
Esempio n. 2
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            CheckBox chkbox = new CheckBox();

            foreach (GridViewRow grdRow in GridView2.Rows)
            {
                chkbox = (CheckBox)Convert.ChangeType(((CheckBox)grdRow.FindControl("CheckBox1")), typeof(CheckBox));
                if (chkbox.Checked)
                {
                    string keyID = (string)GridView2.DataKeys[grdRow.RowIndex].Value.ToString();
                    JV.UpdateParameters["VJA_ID"].DefaultValue = keyID;
                    JV.Update();
                }
            }
        }
Esempio n. 3
0
        protected void Confirm_Click(object sender, EventArgs e)
        {
            CheckBox chkbox = new CheckBox();

            foreach (GridViewRow grdRow in GridView2.Rows)
            {
                chkbox = (CheckBox)Convert.ChangeType(((CheckBox)grdRow.FindControl("CheckBox1")), typeof(CheckBox));
                if (chkbox.Checked)
                {
                    string keyID = (string)GridView2.DataKeys[grdRow.RowIndex].Value.ToString();
                    JV.UpdateParameters["VJA_ID"].DefaultValue = keyID;
                    JV.Update();


                    //EXTENDEndDATE   string ExtendDeactiveDate = "UPDATE Volunteer SET V_Deactive = "
                    //UPDATE Activity status to be End ANd Volunteer Status to be Active
                }
            }
        }
        protected void btnSave_Click(object sender, EventArgs e)
        {
            CheckBox chkbox = new CheckBox();

            foreach (GridViewRow grdRow in GridView2.Rows)
            {
                chkbox = (CheckBox)Convert.ChangeType(((CheckBox)grdRow.FindControl("CheckBox1")), typeof(CheckBox));
                if (chkbox.Checked)
                {
                    string keyID = (string)GridView2.DataKeys[grdRow.RowIndex].Value.ToString();
                    JV.UpdateParameters["VJA_ID"].DefaultValue = keyID;
                    JV.Update();

                    string extend = "UPDATE Volunteer SET V_Status = 'Active', V_DeactiveDate = (SELECT DATEADD(Day,365,Activity_EndDate) as newDeactivedate FROM Activities WHERE Activity_ID = " + GridView1.SelectedRow.Cells[1].ToString() + ") WHERE V_ID = " + keyID + ";";
                    dbconn.QueryExecuteScalar(extend);

                    string    CheckTM = "SELECT V_ID, TT_ID FROM TeamMembers WHERE TT_ID = " + GridView1.SelectedRow.Cells[8].Text + " AND V_ID = " + keyID + "; ";
                    DataTable TM      = dbconn.QueryExecuteScalar(CheckTM);
                    try
                    {
                        if (TM.Rows.Count == 1)
                        {
                        }
                    }
                    catch
                    {
                        string TMDate   = DateTime.Now.Date.ToString("yyyy-MM-dd");
                        string AddnewTM = "INSERT INTO TeamMembers(V_ID,TT_ID,TM_Date) VALUES (" + keyID + "," + GridView1.SelectedRow.Cells[8].Text + ", '" + TMDate + "');";
                        dbconn.QueryExecuteScalar(AddnewTM);
                    }
                }
            }

            string CloseActivity = "UPDATE Activities SET Activity_Status = 'End' WHERE Activity_ID = " + GridView1.SelectedRow.Cells[1].ToString() + ";";

            dbconn.QueryExecuteScalar(CloseActivity);
            dbconn.Close();
            PanelDone.Visible = true;
        }
        protected void btnSave_Click(object sender, EventArgs e)
        {
            string    checkCloseDate = "SELECT Activity_EndDate, DATEDIFF(day,Activity_EndDate,GetDate()) AS Closetime FROM Activities WHERE Activity_ID = " + DetailsView1.DataKey.Value + ";";
            DataTable dt             = dbconn.QueryExecuteScalar(checkCloseDate);
            int       Closeday       = Convert.ToInt32(dt.Rows[0]["Closetime"]);

            if (Closeday < 0)
            {
                MessageBox.Show("Sorry! you are unable to select joined volunteers or close the activity at this time. ");
            }
            else
            {
                CheckBox chkbox = new CheckBox();

                foreach (GridViewRow grdRow in GridView2.Rows)
                {
                    chkbox = (CheckBox)Convert.ChangeType(((CheckBox)grdRow.FindControl("CheckBox1")), typeof(CheckBox));
                    if (chkbox.Checked)
                    {
                        string keyID = (string)GridView2.DataKeys[grdRow.RowIndex].Value.ToString();
                        JV.UpdateParameters["VJA_ID"].DefaultValue = keyID;
                        JV.Update();


                        string extend = "UPDATE Volunteer SET V_Status = 'Active', V_DeactiveDate = (SELECT DATEADD(Day,365,Activity_EndDate) as newDeactivedate FROM Activities WHERE Activity_ID = " + GridView1.SelectedRow.Cells[1].ToString() + ") WHERE V_ID = " + keyID + ";";
                        dbconn.QueryExecuteScalar(extend);
                    }
                }
                string CloseActivity = "UPDATE Activities SET Activity_Status = 'End' WHERE Activity_ID = " + DetailsView1.DataKey.Value.ToString() + ";";
                dbconn.QueryExecuteScalar(CloseActivity);


                PanelSelected.Visible = false;
                PanelGADetail.Visible = false;
                PanelDone.Visible     = true;
                dbconn.Close();
            }
        }
        protected void Confirm_Click(object sender, EventArgs e)
        {
            CheckBox chkbox = new CheckBox();

            foreach (GridViewRow grdRow in GridView2.Rows)
            {
                chkbox = (CheckBox)Convert.ChangeType(((CheckBox)grdRow.FindControl("CheckBox1")), typeof(CheckBox));
                if (chkbox.Checked)
                {
                    string keyID = (string)GridView2.DataKeys[grdRow.RowIndex].Value.ToString();
                    JV.UpdateParameters["VJA_ID"].DefaultValue = keyID;
                    JV.Update();

                    string extend = "UPDATE Volunteer SET V_Status = 'Active', V_DeactiveDate = (SELECT DATEADD(Day,365,Activity_EndDate) as newDeactivedate FROM Activities WHERE Activity_ID = " + GridView1.SelectedRow.Cells[1].ToString() + ") WHERE V_ID = " + keyID + ";";
                    dbconn.QueryExecuteScalar(extend);
                }
            }
            string CloseActivity = "UPDATE Activities SET Activity_Status = 'End' WHERE Activity_ID = " + GridView1.SelectedRow.Cells[1].ToString() + ";";

            dbconn.QueryExecuteScalar(CloseActivity);
            dbconn.Close();
            PanelDone.Visible = true;
        }
Esempio n. 7
0
        public static string AddData(Company oCompany, JV model)
        {
            SAPbobsCOM.JournalVouchers oObject;
            RTNMANVAL rtn = new RTNMANVAL();
            int       errCode; string errMessage, strResult = "";
            string    GetCoa = string.Empty;

            try
            {
                oCompany.StartTransaction();

                oObject = oCompany.GetBusinessObject(BoObjectTypes.oJournalVouchers);
                oObject.JournalEntries.ReferenceDate = model.Refdate;
                oObject.JournalEntries.DueDate       = model.DueDate;
                oObject.JournalEntries.TaxDate       = model.TaxDate;
                oObject.JournalEntries.Reference     = model.Ref1;
                oObject.JournalEntries.Reference2    = model.Ref2;
                oObject.JournalEntries.Reference3    = model.Ref3;
                oObject.JournalEntries.Memo          = model.Remarks;

                oObject.JournalEntries.UserFields.Fields.Item("U_MaximoId").Value     = model.MaximoId;
                oObject.JournalEntries.UserFields.Fields.Item("U_MaximoNumber").Value = model.MaximoNumber;

                if (model.ProjectId != null)
                {
                    if (model.ProjectId != "")
                    {
                        oObject.JournalEntries.ProjectCode = model.ProjectId;
                    }
                }

                for (int i = 0; i < model.Lines.Count; i++)
                {
                    string[] ParamAccount = model.Lines[i].AccountCode.Split('-');

                    if (ParamAccount.Count() > 0)
                    {
                        GetCoa = getConvertCOA(oCompany, ParamAccount[0], ParamAccount[1], ParamAccount[2]);
                    }
                    else
                    {
                        GetCoa = model.Lines[i].AccountCode;
                    }

                    oObject.JournalEntries.Lines.AccountCode = GetCoa;
                    oObject.JournalEntries.Lines.Debit       = Convert.ToDouble(model.Lines[i].DebitAmount);
                    oObject.JournalEntries.Lines.Credit      = Convert.ToDouble(model.Lines[i].CreditAmount);
                    oObject.JournalEntries.Lines.LineMemo    = model.Lines[i].LineMemo;

                    if (model.Lines[i].ref1 != null)
                    {
                        oObject.JournalEntries.Lines.AdditionalReference = model.Lines[i].ref1;
                    }
                    if (model.Lines[i].ref1 != null)
                    {
                        oObject.JournalEntries.Lines.Reference1 = model.Lines[i].ref2;
                    }
                    if (model.Lines[i].ref2 != null)
                    {
                        oObject.JournalEntries.Lines.Reference2 = model.Lines[i].ref3;
                    }
                    if (model.Lines[i].DebitAmountFC != 0 || model.Lines[i].CreditAmountFC != 0)
                    {
                        oObject.JournalEntries.Lines.FCCurrency = model.Lines[i].FCCurrency;
                        oObject.JournalEntries.Lines.FCDebit    = Convert.ToDouble(model.Lines[i].DebitAmountFC);
                        oObject.JournalEntries.Lines.FCCredit   = Convert.ToDouble(model.Lines[i].CreditAmountFC);
                    }

                    if (model.Lines[i].CostCenter != null)
                    {
                        if (model.Lines[i].CostCenter != "")
                        {
                            oObject.JournalEntries.Lines.CostingCode = model.Lines[i].CostCenter;
                        }
                    }
                    oObject.JournalEntries.Lines.Add();
                }
                int statusJV = oObject.Add();

                if (statusJV == 0)
                {
                    if (strResult == "")
                    {
                        strResult = oCompany.GetNewObjectKey();
                    }
                    else
                    {
                        strResult = strResult + " - " + oCompany.GetNewObjectKey();
                    }
                }
                else
                {
                    if (oCompany.InTransaction)
                    {
                        oCompany.EndTransaction(BoWfTransOpt.wf_RollBack);
                    }

                    oCompany.GetLastError(out errCode, out errMessage);
                    throw new Exception("Error Code : " + errCode + " | Error Message : " + errMessage);
                }
                oCompany.EndTransaction(BoWfTransOpt.wf_Commit);
            }
            catch (Exception)
            {
                if (oCompany.InTransaction)
                {
                    oCompany.EndTransaction(BoWfTransOpt.wf_RollBack);
                }
                ;
                throw;
            }
            return(strResult);
        }